Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

impossible de decode my buffers

I have converted an Android image into an unsigned char* buffer about to use imdecode to store it into a opencv Mat. But it's impossible to correctly show the image. I always have some Access Violation errors.

I tried to store the buffer data into a file and load it after, I also tried to use char* instead of unsigned char*, and also to read a jpeg file with opencv and encode it using

Mat jpegMat; 
jpegMat = cvLoadImage(jpegPath, 1);
cv::vector<uchar> buf;
cv::imencode(".jpg", jpegMat, buf);
res = &buf[0];

but the imdecode refuses to work. I tried every possible alternatives I found on the internet but nothing worked for me Here is the code I currently use:

cv::Mat imgbuf = cv::Mat(height, width, CV_8UC1, inputByteArray);
cv::Mat imgMat =  cv::imdecode(imgbuf, CV_LOAD_IMAGE_COLOR);

neither the "imgbuf" Mat nor the "imgMat" accepts to show itself, returning the exact same error message.

Can anyone tell me what is happening because it's been days that I tried everything without getting any results.

Thanks in advance