Re: partial webcam image transfer

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I'm using V4L2 to capture images from a web cam.  I've tried:

- mmap()
- read()
- libv4l2
- without libv4l2

At low resolutions, such as 160x120 and 320x240, things are typically
good.  But starting at 640x480 and higher resolutions, I often get
only 10% to 25% of the image.  The rest of the bytes in the buffer are
left untouched.

When using mmap buffers, v4l2_buffer.bytesused is much less than
v4l2_buffer.length.
When using read, the ssize_t count is less than the full image.

I'm using a native non-compressed YUYV 4:2:2 format, so I know exactly
how many bytes to expect.  When the full image doesn't come in, it
looks like this:

https://www.ccoderun.ca/tmp/partial_image.jpg

In case it helps, here is some relevant V4L information I dump out
after the capture.  Note the bytes used and length of the memory
mapped buffer, which corresponds to the image linked above:

Filename: "/dev/video0"
Driver name: uvcvideo v4.4.40
Device name: USB 2.0 Camera
Location: usb-0000:00:0b.0-1
Flags: 0x85200001
  The device supports the single-planar API through the Video Capture interface.
  The device supports the struct v4l2_pix_format extended fields.
  The device supports the read() and/or write() I/O methods.
  The device supports the streaming I/O method.
  The driver fills the device_caps field.

Currently selected format:
type: V4L2_BUF_TYPE_VIDEO_CAPTURE
width: 1024
height: 768
pixel format: YUYV
field: V4L2_FIELD_NONE
bytes per line: 2048 bytes
image size: 1572864 bytes
colour space: V4L2_COLORSPACE_DEFAULT

Memory mapped buffer #0:
type: V4L2_BUF_TYPE_VIDEO_CAPTURE
bytes used: 284880 bytes
flags: 73733
field: V4L2_FIELD_NONE
sequence: 0
length: 1572864 bytes
address: 0xb7197000

I've checked things like errno and xioctl results to ensure no errors
are reported.  Does anyone have a guess as to why the buffers aren't
always full, or what I must do to ensure I get the whole buffer/read?

TIA,

Stéphane Charette




[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux