Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Hi, the first thing is that your image type for cv::Mat frame and cv::Mat gray is wrong. YUV images have 3 channels. You initialize the images with 1 channel CV_8UC1 and then you try to use a conversion method for 3 channels CV_YUV2RGB.

Mat frame(640,480,CV_8UC3,0.0); // create an image with 640x480 pixel, 3 channels and 8bit per channel
memcpy(frame.data,yuvframebuffer,bufferLen);
Mat gray(640,480,CV_8UC3,0.0);  
cvtColor(frame, gray,CV_YUV2RGB_YV12);

For future questions, please add the error message to your post. This is very helpful for people who want to help you.

Hi, the first thing is that your image type for cv::Mat frame and cv::Mat gray is wrong. YUV images have 3 channels. channels and also RGB images. You initialize the images with 1 channel CV_8UC1 (CV_8UC1) and then you try to use a conversion method for 3 channels CV_YUV2RGB. CV_YUV2RGB.

Mat frame(640,480,CV_8UC3,0.0); // create an image with 640x480 pixel, 3 channels and 8bit per channel
memcpy(frame.data,yuvframebuffer,bufferLen);
Mat gray(640,480,CV_8UC3,0.0);  
cvtColor(frame, gray,CV_YUV2RGB_YV12);

For future questions, please add the error message to your post. This is very helpful for people who want to help you.