I have a small problem with the size of my buffers in a C++ program. I grab YUYV images from a camera using V4L2 (an example is available here )
I want to take one image and put it into a my own image structure. Here is the buffer given by the V4L2 structure and its size
(uchar*)buffers_[buf.index].start, buf.bytesused
In my structure, I create a new buffer (mybuffer) with a size of width*height*bitSize (byte size is 4 since I grab YUYV or YUV422 images).
The problem is that I was expecting the buffer buf to be the same size as the one that I created. But this is not the case, for example when I grab a 640*480 image buf=614400 and mybuffer=1228800 (twice as big).
Does anyone have any idea why this is the case ?
YUV422 uses 4 bytes per 2 pixels
In YUV422 mode the
U
ansV
values are shared between two pixels. The bytes in the Image are ordered likeU0 Y0 V0 Y1 U2 Y2 V2 Y3
etc.Giving pixels like: