-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpan.c
More file actions
55 lines (49 loc) · 1.21 KB
/
Copy pathpan.c
File metadata and controls
55 lines (49 loc) · 1.21 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
#include "stdio.h"
#include <sys/ioctl.h>
#include <linux/videodev2.h>
int pantilt(int dev, int pan, int tilt, int reset)
{
struct v4l2_ext_control xctrls[2];
struct v4l2_ext_controls ctrls;
if (reset > 0) {
switch (reset)
{
case 1:
xctrls[0].id = V4L2_CID_PAN_RESET;
xctrls[0].value = 1;
break;
case 2:
xctrls[0].id = V4L2_CID_TILT_RESET;
xctrls[0].value = 1;
break;
}
ctrls.count = 1;
ctrls.controls = xctrls;
} else {
xctrls[0].id = V4L2_CID_PAN_RELATIVE;
xctrls[0].value = pan;
xctrls[1].id = V4L2_CID_TILT_RELATIVE;
xctrls[1].value = tilt;
ctrls.count = 2;
ctrls.controls = xctrls;
}
if ( ioctl(dev, VIDIOC_S_EXT_CTRLS, &ctrls) < 0 )
{
perror("VIDIOC_S_EXT_CTRLS - Pan/Tilt error. Are the extended controls available?\n");
return -1;
} else {
printf("PAN/TILT Success");
}
return 0;
}
int main() {
printf("Hello, pan-tilting test\n");
int dev;
dev = open("/dev/video1", 0);
if (dev < 0) {
printf ("Can't open device file");
}
pantilt(dev,0,0,2);
close(dev);
printf("Goodbye\n");
}