-
Notifications
You must be signed in to change notification settings - Fork 0
/
v4l2_con.cpp
52 lines (48 loc) · 1.57 KB
/
v4l2_con.cpp
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
#include <sys/ioctl.h>
#include <iostream>
#include <fcntl.h>
#include <linux/videodev2.h>
#include "v4l2_con.h"
using namespace std;
void V4L2_con::v4l2_set_exposure(const char* file_name, int exposure)
{
int Handle = open(file_name, O_RDWR);
struct v4l2_control exp_set;
exp_set.id = V4L2_CID_EXPOSURE_AUTO;
exp_set.value = 1;
ioctl(Handle, VIDIOC_S_CTRL, &exp_set);
cout << "auto_exposure : " << exp_set.value << endl; // 设置自动曝光作为参考
exp_set.id = V4L2_CID_EXPOSURE_ABSOLUTE;
exp_set.value = exposure;
ioctl(Handle, VIDIOC_S_CTRL, &exp_set);
}
void V4L2_con::v4l2_set_saturation(const char* file_name, int saturation)
{
int Handle = open(file_name, O_RDWR);
struct v4l2_control sat_ctrl;
sat_ctrl.id = V4L2_CID_SATURATION;
sat_ctrl.value = saturation;
ioctl(Handle, VIDIOC_S_CTRL, &sat_ctrl);
}
void V4L2_con::v4l2_get_saturation(const char* file_name)
{
int Handle = open(file_name, O_RDWR);
struct v4l2_control sat_get;
sat_get.id = V4L2_CID_SATURATION;
cout << "saturation : " << sat_get.value << endl;
}
void V4L2_con::v4l2_set_brightness(const char* file_name, int saturation)
{
int Handle = open(file_name, O_RDWR);
struct v4l2_control bri_ctrl;
bri_ctrl.id = V4L2_CID_BRIGHTNESS;
bri_ctrl.value = saturation;
ioctl(Handle, VIDIOC_S_CTRL, &bri_ctrl);
}
void V4L2_con::v4l2_get_brightness(const char* file_name)
{
int Handle = open(file_name, O_RDWR);
struct v4l2_control bri_get;
bri_get.id = V4L2_CID_BRIGHTNESS;
cout << "brightness : " << bri_get.value << endl;
}