YUV422 image appears only gray
Hello,
I Need to preview camera Images gathering YUV422 Format data into a buffer. The following code works fine, but only as gray image:
IplImage *pYuvImage;
pYuvImage = cvCreateImage(cvSize(SizeX, SizeY), IPL_DEPTH_16U, 1);
pYuvImage->imageData = (char*)buffer;
cvNamedWindow("MyImage");
cvShowImage("MyImage", pYuvImage);
cvWaitKey();
cvDestroyWindow("MyImage");
cvReleaseImage(&pYuvImage);
Now actually I need to have a color Image window, so I tried following:
IplImage *pBgrImage;
pBgrImage = cvCreateImage(cvSize(SizeX, SizeY), IPL_DEPTH_8U, 3);
IplImage *pYuvImage;
pYuvImage = cvCreateImage(cvSize(SizeX, SizeY), IPL_DEPTH_16U, 1);
pYuvImage->imageData = (char*)buffer;
cvCvtColor(pYuvImage, pBgrImage, CV_YUV2RGB);
cvNamedWindow("MyImage");
cvShowImage("MyImage", pYuvImage);
cvWaitKey();
cvDestroyWindow("MyImage");
cvReleaseImage(&pYuvImage);
Now cvCvtColor fails with an exception accessing wrong Memory. What goes wrong ? Remember, gray works fine - any help is appreciated.
Regards, Jürgen