-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgst_main.cpp
113 lines (104 loc) · 4.6 KB
/
gst_main.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
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
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
#include <string.h>
#include <sys/ioctl.h>
#include <fstream>
void printHelp();
/************************************************
*Main fuction
************************************************/
int main(){
int isRunning = 1;
char input;
int err =0;
printHelp();
while (isRunning){
printf(">");
scanf(" %c",&input);
switch (input)
{
//General functions
case 'h': //print help
printHelp();
break;
case 'q': //quit menu
isRunning=0;
break;
case 'c': //clear terminal
system("clear");
break;
//Application specific
case '1': //Simple video stream
system("echo PRESS 'CTRL+C' TO STOP THE STREAM");
system("v4l2-ctl -d /dev/video0 --set-fmt-video=width=1920,height=1080,pixelformat='GREY' --set-ctrl sensor_mode=2");
system("gst-launch-1.0 v4l2src ! queue ! videoconvert ! queue ! xvimagesink sync=false");
printHelp();
break;
case '2': //Autofocus: manual control
system("echo PRESS 'A' TO START AUTOFOCUS");
system("echo PRESS 'CTRL+C' TO STOP THE STREAM");
system("echo Focus calculated within an ROI: 200x100");
system("v4l2-ctl -d /dev/video0 --set-fmt-video=width=1920,height=1080,pixelformat='GREY' --set-ctrl sensor_mode=2");
system("gst-launch-1.0 v4l2src ! autofocus step_small=5 offset=2 continuous=false continuous_update_interval=5 x=860 y=440 width=200 height=100 ! queue ! videoconvert ! queue ! xvimagesink sync=false");
printHelp();
break;
case '3': //Autofocus: manual control + Bacode decoding
system("echo PRESS 'A' TO START AUTOFOCUS");
system("echo PRESS 'CTRL+C' TO STOP THE STREAM");
system("echo Focus calculated within an ROI: 200x100");
system("echo Number of decoded barcode per image: 1");
system("v4l2-ctl -d /dev/video0 --set-fmt-video=width=1920,height=1080,pixelformat='GREY' --set-ctrl sensor_mode=2");
system("gst-launch-1.0 v4l2src ! autofocus step_small=5 offset=2 continuous=false continuous_update_interval=5 x=860 y=440 width=200 height=100 ! barcodereader framing=false type=all ! queue ! videoconvert ! queue ! xvimagesink sync=false");
printHelp();
break;
case '4': //Autofocus: continuous
system("echo PRESS 'A' TO START AUTOFOCUS");
system("echo PRESS 'CTRL+C' TO STOP THE STREAM");
system("echo Focus calculated within an ROI: 200x100");
system("v4l2-ctl -d /dev/video0 --set-fmt-video=width=1920,height=1080,pixelformat='GREY' --set-ctrl sensor_mode=2");
system("gst-launch-1.0 v4l2src ! autofocus step_small=5 offset=2 continuous=true continuous_update_interval=5 x=860 y=440 width=200 height=100 ! queue ! videoconvert ! queue ! xvimagesink sync=false");
printHelp();
break;
case '5': //Autofocus: continuous + Bacode decoding
system("echo PRESS 'A' TO START AUTOFOCUS");
system("echo PRESS 'CTRL+C' TO STOP THE STREAM");
system("echo Focus calculated within an ROI: 200x100");
system("echo Number of decoded barcode per image: 1");
system("v4l2-ctl -d /dev/video0 --set-fmt-video=width=1920,height=1080,pixelformat='GREY' --set-ctrl sensor_mode=2");
system("gst-launch-1.0 v4l2src ! autofocus step_small=5 offset=2 continuous=true continuous_update_interval=5 x=860 y=440 width=200 height=100 ! barcodereader framing=false type=all ! queue ! videoconvert ! queue ! xvimagesink sync=false");
printHelp();
break;
case '6': //Fixed-focus module: Bacode decoding
system("echo PRESS 'CTRL+C' TO STOP THE STREAM");
system("echo Number of decoded barcode per image: 5");
system("v4l2-ctl -d /dev/video0 --set-fmt-video=width=1920,height=1080,pixelformat='GREY' --set-ctrl sensor_mode=2");
system("gst-launch-1.0 v4l2src ! barcodereader framing=false type=all number-barcode=5 ! queue ! videoconvert ! queue ! xvimagesink sync=false");
printHelp();
break;
default:
printf("Wrong input!\n\n");
printHelp();
}
if (err != 0) isRunning = 0;
}
return 0;
}
/************************************************
*Print help
************************************************/
void printHelp(){
system("clear");
printf("\nTELEDYNE-E2V OPTIMOM 2M Module running with Nvidia Jetson Nano\n");
printf("\nGSTREAMER CONTROL\n");
printf("Tools menu:\n");
printf("\t1:\tSimple video stream\n");
printf("\t2:\tAutofocus manual control\n");
printf("\t3:\tAutofocus manual control + Barcode decoding\n");
printf("\t4:\tAutofocus continuous mode\n");
printf("\t5:\tAutofocus continuous mode + Barcode decoding\n");
printf("\t6:\tFixed-focus module: Barcode decoding\n");
printf("\tc:\tclear window\n");
printf("\th:\tprint this help\n");
printf("\tq:\tquit\n");
}