Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

YUV422 immage appears only gray

Hello,

I Need to preview camera Images gathering in YUV422 Format 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

YUV422 immage image appears only gray

Hello,

I Need to preview camera Images gathering in 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