OpenCV: Convert char* to cv::Mat-Collection of common programming errors
I want to develop a server-client face recognition application. My problem is when I try to convert the picture received as a char* to cv::Mat, I get the following error: “Unhandled exception at 0x61ed3ea0 (opencv_highgui249d.dll) in …exe: 0xC0000005:Access violation reading location 0x00431000.”
This is my code for cliend application (send Mat image as a String):
matCameraBitmap = new Mat();
//...
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream()));
out.write(matCameraBitmap.toString());
out.flush();
and the code server application (receive image as char*):
char buffer[1024];
memset(buffer, 0, buffer_len);
if((bytecount = recv(new_sock, buffer, buffer_len, 0)) == SOCKET_ERROR)
{
fprintf(stderr, "Error receiving data %d\n", WSAGetLastError());
goto END;
}
TempMat = cv::Mat(100, 100, CV_8UC1, buffer); //all images are 100x100
imshow("this is a test", TempMat);
Do you have any idea how to solve this error?