V4l2 Getting camera information

Source: Internet
Author: User

This program output camera driver, code stream format and other information
#include <stdio.h>#include<stdlib.h>//stdio.h and Stdlib.h is needed by perror function#include <sys/stat.h>#include<sys/types.h>#include<fcntl.h>//O_rdwr#include <unistd.h>#include<sys/mman.h>//Unistd.h and Sys/mman.h is needed by mmap function#include <stdbool.h>//false and True#include <sys/ioctl.h>#include<linux/videodev2.h>//v4l2 APIStatic intVideo_capability (intFD) { intRET =0; /***********get the device capability********/ structv4l2_capability Cap; RET= IOCTL (FD, VIDIOC_QUERYCAP, &cap); if(Ret <0) {perror ("Vidioc_querycap failed"); returnret; } printf ("\n****capability informations****\n"); printf ("Driver:%s\n", Cap.driver); if(Cap.capabilities &v4l2_cap_video_capture) printf ("Capture capability is supported\n"); if(Cap.capabilities &v4l2_cap_streaming) printf ("streaming capability is supported\n"); if(Cap.capabilities &v4l2_cap_video_overlay) printf ("Overlay capability is supported\n"); return 0; } Static intVideo_fmtdesc (intFD) { /***********format enumeration************/ intRET =0; structV4l2_fmtdesc fmtdes; //CLEAR (fmtdes); Fmtdes.index =0; Fmtdes.type=v4l2_buf_type_video_capture; printf ("\N**********VIDIOC Enumeration stream format informations:****\n"); while(1) {ret= IOCTL (FD, VIDIOC_ENUM_FMT, &fmtdes); if(Ret <0) Break; printf ("{PixelFormat =%c%c%c%c, description =%s}\n", (Fmtdes.pixelformat&0xFF), (Fmtdes.pixelformat>>8) &0xFF, (Fmtdes.pixelformat>> -) &0xFF, (Fmtdes.pixelformat>> -) &0xFF, fmtdes.description); if(Fmtdes.type = =v4l2_buf_type_video_capture) printf ("Video Capture type:\n"); if(Fmtdes.pixelformat = =v4l2_pix_fmt_yuyv) printf ("v4l2_pix_fmt_yuyv\n"); if(Fmtdes.pixelformat = =v4l2_pix_fmt_yuv420) printf ("v4l2_pix_fmt_yuv420\n"); if(Fmtdes.pixelformat = =v4l2_pix_fmt_rgb24) printf ("v4l2_pix_fmt_rgb24\n"); if(Fmtdes.pixelformat = =v4l2_pix_fmt_yuv422p) printf ("v4l2_pix_fmt_yuv422p\n"); if(Fmtdes.pixelformat = =v4l2_pix_fmt_uyvy) printf ("v4l2_pix_fmt_uyvy\n"); Fmtdes.index++; } return 0; } voidMain () {intFD = open (Default_device, O_RDWR | O_nonblock,0); Video_capability (FD); Video_fmtdesc (FD); }

The code should still be available, and you can't use it to tell me.

V4l2 as if the Ubuntu system comes with, if not the installation is also very convenient, like sudo apt-get install Libv4l-dev, Baidu a bit

V4l2 Getting camera information

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.