#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<sys/types.h>
#include<fcntl.h>
#include<linux/videodev2.h>
/*摄像头开关*/
//#define XXXX_150
/*摄像头参数id列表*/
#define BRIGHTNESS_ID 0x00980900
#define CONTRAST_ID 0x00980901
#define SATURATION_ID 0x00980902
#define HUE_ID 0x00980903
#define WHITE_BALANCE_TEMP_AUTO_ID 0x0098090c
#define GAMMA_ID 0x00980910
#define POWER_LINE_FREQUENCY_ID 0x00980918
#define WHITE_BALANCE_TEMP_ID 0x0098091a
#define SHARPNESS_ID 0x0098091b
#define BACKLIGHT_COMPENSATION_ID 0x0098091c
#define EXPOSURE_AUTO_ID 0x009a0901
#define EXPOSURE_ABSOLUTE_ID 0x009a0902
#define EXPOSURE_AUTO_PRIORITY_ID 0x009a0903
struct v4l2_capability cap;
struct v4l2_queryctrl qctrl;
struct v4l2_control ctrl;
struct v4l2_format Format;
struct v4l2_streamparm Stream_Parm;
void get_v4l2_info(int fd)
{
printf("************************Get format info********************************\n");
Format.type= V4L2_BUF_TYPE_VIDEO_CAPTURE;
if(ioctl(fd,VIDIOC_G_FMT,&Format)==-1)
{
perror("ioctl");
exit(EXIT_FAILURE);
}
printf(">:[width:%d]\t[pixelformat:%d]\n",Format.fmt.pix.width,Format.fmt.pix.height);
printf(">:[format:%d]\t[field:%d]\n",Format.fmt.pix.pixelformat,Format.fmt.pix.field);
printf(">:[bytesperline:%d]\t[sizeimage:%d]\n",Format.fmt.pix.bytesperline,Format.fmt.pix.sizeimage);
printf(">:[colorspace:%d]\n",Format.fmt.pix.colorspace);
printf("***********************************************************************\n");
printf("\n");
printf("************************Get Stream_Parm********************************\n");
Stream_Parm.type=V4L2_BUF_TYPE_VIDEO_CAPTURE;
if(ioctl(fd,VIDIOC_G_PARM,&Stream_Parm)==-1)
{
perror("ioctl");
exit(EXIT_FAILURE);
}
printf(">:[Frame rate:%u] [%u]\n",Stream_Parm.parm.capture.timeperframe.numerator,Stream_Parm.parm.capture.timeperframe.denominator);
printf(">:[capability:%d] [capturemode:%d]\n",Stream_Parm.parm.capture.capability,Stream_Parm.parm.capture.capturemode);
printf(">:[extendemode:%d] [readbuffers:%d]\n",Stream_Parm.parm.capture.extendedmode,Stream_Parm.parm.capture.readbuffers);
printf("***********************************************************************\n");
printf("\n");
printf("*************************Get Exposure Auto*****************************\n");
ctrl.id=EXPOSURE_AUTO_ID;
if(ioctl(fd,VIDIOC_G_CTRL,&ctrl)==-1)
{
perror("ioctl");
exit(EXIT_FAILURE);
}
printf(">:Get Exposure Auto:[
V4L2设置摄像头光照,对比度参数
最新推荐文章于 2024-07-02 16:10:23 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)