In general there are following main ways to make a capturing:
Each call to the read syscall returns the next available image from the
device. It is up to the caller to set format and size (using the
VIDIOCSPICT and VIDIOCSWIN ioctls) and then to pass a suitable size
buffer and length to the function. Not all devices will support read
operations.
A second way to handle image capture is via the mmap interface if
supported. To use the mmap interface a user first sets the desired image
size and depth properties. Next the VIDIOCGMBUF ioctl is issued. This
reports the size of buffer to mmap and the offset within the buffer for
each frame. The number of frames supported is device dependent and may
only be one.
Once the mmap has been made the VIDIOCMCAPTURE ioctl starts the capture
to a frame using the format and image size specified in the video_mmap
(which should match or be below the initial query size). When the
VIDIOCMCAPTURE ioctl returns the frame is not captured yet, the driver
just instructed the hardware to start the capture. The application has
to use the VIDIOCSYNC ioctl to wait until the capture of a frame is
finished. VIDIOCSYNC takes the frame number you want to wait for as
argument.
It is allowed to call VIDIOCMCAPTURE multiple times (with different
frame numbers in video_mmap->frame of course) and thus have multiple
outstanding capture requests. A simple way do to double-buffering using
this feature looks like this:
/* setup everything */
VIDIOCMCAPTURE(0)
while (whatever) {
VIDIOCMCAPTURE(1)
VIDIOCSYNC(0)
/* process frame 0 while the hardware captures frame 1 */
VIDIOCMCAPTURE(0)
VIDIOCSYNC(1)
/* process frame 1 while the hardware captures frame 0 */
}
Note that you are not limited to only two frames. The API allows up to
32 frames, the VIDIOCGMBUF ioctl returns the number of frames the driver
granted. Thus it is possible to build deeper queues to avoid loosing
frames on load peaks.
While capturing to memory the driver will make a "best effort" attempt
to capture to screen as well if requested. This normally means all
frames that "miss" memory mapped capture will go to the display.
But I recommend you to read v4l docs...
regards,
Serguei.
Jeffrey Dever wrote:
I'm perplexed as to how to read captures from the video device. I can
do quite a bit to control my webcam (probe, set window ...) but there
seems to be several modes of reading captures. I'm just trying to do
a simple capture, so I don't want to use mmap at this point as I want
to keep it as simple as possible.
I expect to use VIDIOCCAPTURE. I can see that we call this ioctl to
start capturing, but don't see how to read the data. Do we start
capturing, do a read() and then stop capturing? What is the sequence
of steps?
--
video4linux-list mailing list
Unsubscribe
mailto:video4linux-list-request@xxxxxxxxxx?subject=unsubscribe
https://listman.redhat.com/mailman/listinfo/video4linux-list
--
****************************************
Dr. Serguei Boldyrev
Control Systems Research Engineer
Samsung Advanced Institute of Technology
P.O Box 111
Suwon 440-600
South Korea
tel: +82-31-280-9230
fax: +82-31-280-6955
email: Sergey.Boldyrev@xxxxxxxx
boldyrev@xxxxxxxxxxxxxxxxxx
ICQ: 39917156
****************************************