Ask Your Question

syberarall's profile - activity

2019-02-28 10:02:00 -0500 received badge  Notable Question (source)
2018-11-06 04:41:57 -0500 received badge  Famous Question (source)
2017-04-26 00:21:57 -0500 received badge  Popular Question (source)
2016-02-08 10:15:16 -0500 received badge  Notable Question (source)
2015-03-08 07:18:09 -0500 received badge  Popular Question (source)
2013-09-15 12:08:13 -0500 asked a question Convert BayerBG12Packed (12-Bit packed) into RGB

Hello,

can anyone tell me, what code inside cvtColor has to be used, when converting 12 bit packed BayerBG12Packed into RGB. The following code does not work:

cv::Mat Mat16Bit(SizeY, SizeX, CV_16UC1, ImageData);
cv::Mat Mat8Bit = Mat16Bit.clone();
Mat8Bit.convertTo(Mat8Bit, CV_8UC3, 0.0625);
cv::Mat MatRgb(SizeY, SizeX, CV_8UC3);
cv::cvtColor(Mat8Bit, MatRgb, CV_BayerBG2RGB);

image MyImage

BayerBG12 works fine, so maybe the image sizes do not match - any help is welcome.

2013-09-12 13:00:46 -0500 answered a question YUV422 image appears only gray

Now I got the solution - the following code works fine:

 IplImage *pRgbImage;
  pRgbImage = cvCreateImage(cvSize(SizeX, SizeY), IPL_DEPTH_8U, 3);

  IplImage *pYuvImage;
  pYuvImage = cvCreateImage(cvSize(SizeX, SizeY), IPL_DEPTH_8U, 2);
  pYuvImage->imageData = (char*)buffer;

  cvCvtColor(pYuvImage, pRgbImage, CV_YUV2RGB);

  cvNamedWindow("MyImage");
  cvShowImage("MyImage", pRgbImage);
  cvWaitKey();
  cvDestroyWindow("MyImage");
  cvReleaseImage(&pRgbImage);

But I still have Problems converting BayerBG12:

 IplImage *pRgbImage;
  pRgbImage = cvCreateImage(cvSize(SizeX, SizeY), IPL_DEPTH_8U, 3);

  IplImage *pYuvImage;
  pBg12Image = cvCreateImage(cvSize(SizeX, SizeY), IPL_DEPTH_8U, 2);
  pBg12Image->imageData = (char*)buffer;

  cvCvtColor(pBg12Image, pRgbImage, CV_BayerBG2RGB);

  cvNamedWindow("MyImage");
  cvShowImage("MyImage", pRgbImage);
  cvWaitKey();
  cvDestroyWindow("MyImage");
  cvReleaseImage(&pRgbImage);

Any suggestions ?

2013-09-10 03:45:36 -0500 commented answer YUV422 image appears only gray

Thanks for the quick Response. But also COLOR_YUV2RGB_Y422 (CV_YUV2RGB_Y422) makes no difference. I have really no idea any more how to solve this Problem, so any help is welcome.

2013-09-09 09:15:05 -0500 received badge  Editor (source)
2013-09-09 09:11:54 -0500 asked a question 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