简体   繁体   English

对V4L2的误解

[英]A misunderstanding of V4L2

I have a small problem with the size of my buffers in a C++ program. 我在C ++程序中的缓冲区大小有一个小问题。 I grab YUYV images from a camera using V4L2 (an example is available here ) 我使用V4L2从相机捕获YUYV图像( 此处提供示例)

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 这是V4L2结构及其大小给出的缓冲区

(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). 在我的结构中,我创建了一个新缓冲区(mybuffer),其大小为width * height * bitSize(字节大小为4,因为我抓到YUYV或YUV422图像)。

The problem is that I was expecting the buffer buf to be the same size as the one that I created. 问题是我期望缓冲区buf与我创建的缓冲区大小相同。 But this is not the case, for example when I grab a 640*480 image buf=614400 and mybuffer=1228800 (twice as big). 但是情况并非如此,例如,当我抓取一个640 * 480的图像buf = 614400和mybuffer = 1228800(两倍大)时。

Does anyone have any idea why this is the case ? 有谁知道为什么会这样吗?

YUV422 uses 4 bytes per 2 pixels YUV4222像素使用4个字节

In YUV422 mode the U ans V values are shared between two pixels. YUV422模式下, U ans V值在两个像素之间共享。 The bytes in the Image are ordered like U0 Y0 V0 Y1 U2 Y2 V2 Y3 etc. 映像中的字节按如下顺序排列: U0 Y0 V0 Y1 U2 Y2 V2 Y3等。

Giving pixels like: 提供像这样的像素:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM