Specifications
Figure 19 shows the flow chat of photos grabbing, it has five steps,
using the Video4Linux was described as following:
Open the video device:
The hardware devices in Linux would be the files, the video device
would be the ‘/dev/video0’ file when the driver started as explained in 3-2-3 .
Using the ‘open’ system call which could open the video device for
controlling, the C code shows as following:
if ((fd = open (“/dev/video0”, O_RDWR)) == -1) {
perror ("ERROR opening V4L interface \n");
exit (1);
}
The ‘fd’ is the file descriptor in above C code, using this to control the video
device.
Get the capabilities of video device
VIDIOCGCAP allows the applications to find out what sort of a card
they have found and to figure out what they want to do about it. The camera
capabilities getting can therefore apply the VIDIOCGCAP ioctl at first after
the open step.
if (ioctl (fd, VIDIOCGCAP, &videocap) == -1) {
printf ("wrong device\n");
exit (1);
}
The ‘videocap’ is a structure which contains the camera capabilities; the
Table 1 shows the fields of video_capability Structure:.
name The device text name. This is intended for the user.
channels The number of different channels you can tune on this
card. It could even by zero for a card that has no tuning
capability. For our simple FM radio it is 1.
A
n AM/FM radio
would report 2.
audios The number of audio inputs on this device. For our radio
there is only one audio input.
minwidth,minheight The smallest size the card is capable of capturing images
in. We set these to zero. Radios do not capture pictures
maxwidth,maxheight The largest image size the card is capable of capturing. For
our radio we report 0.
type This reports the capabilities of the device, and matches the
field we filled in in the struct video_device when registering.
Table 1. video_capability Structure Fields
36