Ask Your Question
0

how to load UYUV 4:2:2 frame into opencv?

asked 2014-09-25 12:45:36 -0600

Xiang gravatar image

hi,

I have a frame captured in the format of UYUV 4:2:2, but when I load it into openCV (imread), it seems to be in the wrong format. How can I load UYUV4:2:2 into opencv? is this format support by opencv? Thanks.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-09-26 01:19:43 -0600

Hi @Xiang!

You can use the following code to convert Image from YUV to RGB.

Mat Img_Source_YUV(m_ImgHeight,m_ImgWidth,CV_8UC2);
Mat Img_Destination_Bgr(m_ImgHeight,m_ImgWidth,CV_8UC3);

FILE * f; 
f=fopen(FileName_S.c_str(),"rb");
if ( !f )
{
    MessageBox(L"File Not Found");
    return;
}

uchar* pYUVPixels;//w-2592 h- 1944
UINT32 Img_Size= (m_ImgWidth * m_ImgHeight*2);
pYUVPixels = new uchar[Img_Size];

fread(pYUVPixels,Img_Size,1,f);
fclose(f);

Img_Source_YUV.data= pYUVPixels;

cvtColor(Img_Source_YUV,Img_Destination_Bgr,COLOR_YUV2BGR_Y422);

namedWindow("Img_Destination_Bgr",WINDOW_AUTOSIZE);
imshow("Img_Destination_Bgr",Img_Destination_Bgr);
edit flag offensive delete link more

Comments

Please accept the answer if this solves your problem.

Balaji R gravatar imageBalaji R ( 2014-09-26 07:45:15 -0600 )edit

Question Tools

Stats

Asked: 2014-09-25 12:45:36 -0600

Seen: 766 times

Last updated: Sep 26 '14