V4L2_CameraParameterSetting.c
2.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <getopt.h> /* getopt_long() */
#include <fcntl.h> /* low-level i/o */
#include <unistd.h>
#include <errno.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/time.h>
#include <sys/mman.h>
#include <sys/ioctl.h>
#include <linux/videodev2.h>
#include "./V4L2_CameraParameterSetting.h"
#include "JZsdkLib.h"
#include "../Camera.h"
#include "MediaProc/MediaParm.h"
T_JZsdkReturnCode V4L2_Parameter_Setting(JZsdk_CameraInfo *CameraInfo)
{
struct v4l2_control ctrl;
//设置亮度*
if (CameraInfo->CameraParam.Brightness != 0)
{
ctrl.id= V4L2_CID_BRIGHTNESS;
ctrl.value = CameraInfo->CameraParam.Brightness;
if(ioctl(CameraInfo->CameraFd,VIDIOC_S_CTRL,&ctrl)==-1)
{
JZSDK_LOG_INFO("相机亮度设置失败");
}
}
//设置对比度
if (CameraInfo->CameraParam.Contrast != 0)
{
ctrl.id = V4L2_CID_CONTRAST;
ctrl.value= CameraInfo->CameraParam.Contrast;
if(ioctl(CameraInfo->CameraFd,VIDIOC_S_CTRL,&ctrl)==-1)
{
JZSDK_LOG_INFO("相机对比度设置失败");
}
}
//设置饱和度
if (CameraInfo->CameraParam.Saturation != 0)
{
ctrl.id = V4L2_CID_SATURATION;
ctrl.value= CameraInfo->CameraParam.Saturation;
if(ioctl(CameraInfo->CameraFd,VIDIOC_S_CTRL,&ctrl)==-1)
{
perror("相机饱和度设置失败");
}
}
/*
//设置色度
ctrl.id = V4L2_CID_HUE;
ctrl.value = 1;
if(ioctl(cam_fd,VIDIOC_S_CTRL,&ctrl)==-1)
{
perror("ioctl");
exit(EXIT_FAILURE);
}
//设置手动白平衡
ctrl.id = V4L2_CID_AUTO_WHITE_BALANCE;
ctrl.value = V4L2_WHITE_BALANCE_MANUAL ;
if(ioctl(cam_fd,VIDIOC_G_CTRL,&ctrl)==-1)
{
perror("ioctl");
exit(EXIT_FAILURE);
}
//设置白平衡色温
ctrl.id = V4L2_CID_WHITE_BALANCE_TEMPERATURE;
ctrl.value = 5100;
if(ioctl(cam_fd,VIDIOC_S_CTRL,&ctrl)==-1)
{
perror("ioctl");
exit(EXIT_FAILURE);
}
//设置锐度
ctrl.id = V4L2_CID_SHARPNESS;
ctrl.value = 4;
if(ioctl(cam_fd,VIDIOC_S_CTRL,&ctrl)==-1)
{
perror("ioctl");
exit(EXIT_FAILURE);
}
//设置背光补偿
ctrl.id = V4L2_CID_BACKLIGHT_COMPENSATION;
ctrl.value = 3;
if(ioctl(cam_fd,VIDIOC_S_CTRL,&ctrl)==-1)
{
perror("ioctl");
exit(EXIT_FAILURE);
}
//设置伽玛值
ctrl.id = V4L2_CID_GAMMA;
ctrl.value = 120;
if(ioctl(cam_fd,VIDIOC_S_CTRL,&ctrl)==-1)
{
perror("ioctl");
exit(EXIT_FAILURE);
}
*/
JZSDK_LOG_INFO("V4L2_Parameter_Setting success");
return JZ_ERROR_SYSTEM_MODULE_CODE_SUCCESS;
}