OpenCV how to put jpeg image buffer to cvShowImage
I have a JPG image in buffer and I would try to show it with cvShowImage. This is not working, however:
// buff is a JPEG image with 640*480 dimensions
IplImage* fIplImageHeader;
fIplImageHeader = cvCreateImageHeader(cvSize(640, 480), 8, 1);
fIplImageHeader->imageData = (char *)buff;
cvShowImage("Window 1", fIplImageHeader);
cvWaitKey();
cvReleaseImageHeader(&fIplImageHeader);
开发者_如何学Go
I get a black window with that.
Looks like you forgot to set widthStep
|-- int widthStep; // size of aligned image row in bytes
|-- int imageSize; // image data size in bytes = height*widthStep
精彩评论