Linux camera Programming

Source: Internet
Author: User
This is the development of the camera program in Linux, mainly used in video4linux. The interface is implemented using QT and you are ready to use framebuffer to directly write the screen, but the effect is not very good, later, I used qt to do it. In this way, the effect is quite good, and the frame rate can also be up to 30fps. I used v4l to program and master its API, to increase the frame rate, the most important thing is to use memory ing. In fact, memory ing is used for both QT and framebuffer. Only in this way can a high frame rate be achieved, however, pay attention to resource utilization issues. munmap is required after MMAP. framebuffer is a very interesting thing, especially the driver design.
The Code is as follows:
1. Open device:
Video_dev = open ("\ Dev \ video0", o_rdwr ));
2. Get the information of the Video device
Struct video_capability video_cap;
Memset (& video_cap, 0, sizeof (video_cap ));
If (IOCTL (video_dev, vidiocgcap, & video_cap) =-1)
{
Perror ("cann' t get the information of the Video device ");
Close (video_dev );
Exit (1 );
}
3. Get the information of the channels
Struct video_channel video_chan;
Memset (& video_chan, 0, sizeof (video_chan ));
For (Channel = 0; Channel <video_cap.channels; Channel ++)
{
Video_chan.channel = channel;
If (IOCTL (video_dev, vidiocgchan, & video_chan) =-1)
{
Perror ("cann' t get the information of the channels ");
Close (video_dev );
Exit (3 );
}
If (video_chan.type = video_type_ TV)
{
# Ifdef debug
Printf ("No. % d channel is % s, type is
TV! \ N ", channel, video_chan.name );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.