A misunderstanding of V4L2

佐手、 提交于 2019-12-24 01:09:38

问题


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 ?


回答1:


YUV422 uses 4 bytes per 2 pixels

In YUV422 mode the U ans V values are shared between two pixels. The bytes in the Image are ordered like U0 Y0 V0 Y1 U2 Y2 V2 Y3 etc.

Giving pixels like:

pixel 0   U0Y0V0
pixel 1   U0Y1V0
pixel 2   U2Y2V2
pixel 3   U2Y3V2


来源:https://stackoverflow.com/questions/16379341/a-misunderstanding-of-v4l2

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!