I have a jpeg image in buffer jpegBuffer. I’m trying to pass it to cv::imdecode function:
Mat matrixJprg = imdecode(Mat(jpegBuffer), 1);
I get this error:
/home/richard/Desktop/richard/client/src/main.cc:108: error: no matching function for call to ‘cv::Mat::Mat(char*&)’
This is how I fill jpegBuffer:
FILE* pFile;
long lSize;
char * jpegBuffer;
pFile = fopen ("img.jpg", "rb");
if (pFile == NULL)
{
exit (1);
}
// obtain file size.
fseek (pFile , 0 , SEEK_END);
lSize = ftell (pFile);
rewind (pFile);
// allocate memory to contain the whole file.
jpegBuffer = (char*) malloc (lSize);
if (jpegBuffer == NULL)
{
exit (2);
}
// copy the file into the buffer.
fread (jpegBuffer, 1, lSize, pFile);
// terminate
fclose (pFile);
Mat has no constructor that takes a char* argument. Try this instead:
EDIT:
You should also take a look at LoadImageM.
If you have your data already in a char* buffer one way is to copy the data into an std::vector.