I'm having an YUYV image buffer in cvMat object (snippet shown below). I had to convert this cvMat object to IplImage for color conversion.
CvMat cvmat = cvMat(480, 640, CV_8UC2, yuyv_buff);
I tried the below options to convert this cvmat
object to IplImage
object (src: https://medium.com/@zixuan.wang/mat-cvmat-iplimage-2f9603b43909 ).
//cvGetImage()
CvMat M;
IplImage* img = cvCreateImageHeader(M.size(), M.depth(), M.channels());
cvGetImage(&M, img); //Deep Copy
//Or
CvMat M;
IplImage* img = cvGetImage(&M, cvCreateImageHeader(M.size(), M.depth(), M.channels()));
//cvConvert()
CvMat M;
IplImage* img = cvCreateImage(M.size(), M.depth(), M.channels());
cvConvert(&M, img); //Deep Copy
But nothing worked. cvGetImage()
, cvConvert()
expects cvArr*
as input. Passing &cvmat
to them throws exception.
Is there any other way to convert an CvMat object to IplImage object in OpenCV 2.4 ?
Note: I cannot use C++ API or any other version of OpenCV. I'm limited to use only OpenCV 2.4
Edit 1: My objective is to convert this YUYV buffer to an RGB image object.