# Mat using YUV 422 Video

Hello,

I'd like to write a single videoline, which is stored on DDR-RAM, in a Mat Object.

I have initialized an int-Array and convert it to a Mat Object:


int *Video_Line = (int *) calloc(1920, sizeof(int));
Mat videoline = Mat(1, 1920, CV_8UC3, Video_Line);

Now the write function:

for(int i=0; i <= 1920; i++)
{
unsigned long val = getData((DPRAM_START+i));
Video_Line[i] = val;
}


The output is:


Mat = {99, bc, 12, bc, 99, bc, ...}

That correspond to:

Mat = [Y0, Cr0, Y1, Cb1, Y2, Cr2, ...]

How can I explain MAT, that the data are in YUV 422?

That is important to calculate a histogram.

Best regards,

Michael

edit retag close merge delete

Sort by » oldest newest most voted

Hi Michael!

Probably the best option to this problem, is separate the different channels of your videoline (Y,U and V).

Something like this: Mat yuv422_DDR_RAM = {99, bc, 12, bc, 99, bc, ...}

Mat y = {99,12,99,...} Mat u = {bc,bc,...} Mat v = {bc,...}

After this, you can calculate the histogram of channel Y, using the OpenCV functions and the object cv::Mat y. Repeat the process to channel U and channel V.

If you want the original image you must resize cv::Mat u and cv::Mat v to the same values of width and height of cv::Mat y. After the resizing process you can merge the objects Mat y, u and v.

Cheers, Victor

more

Which are your values for the width and height of the original video ?

( 2015-01-07 17:50:57 -0500 )edit

Official site

GitHub

Wiki

Documentation