-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
76 lines (59 loc) · 1.89 KB
/
Copy pathmain.cpp
File metadata and controls
76 lines (59 loc) · 1.89 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
#include "GradVision.h"
cv::VideoCapture cp;
GradVision test_vision;
cv::Mat frame;
GradVisionResult gabage;
AllParameters_grad all_p;
// #define RUN_ON_DARWIN
int main(int argc, char const *argv[]) {
if (argc == 2) {
// cout<<argv[0]<<' '<<argv[1]<<endl;
cp.open((int)(argv[1][0]-'0'));
}
else if (argc == 3) {
cp.open((int)(argv[1][0]-'0'));
test_vision.LoadParameters(argv[2]);
}
else {
cp.open(0);
}
if (!cp.isOpened()) {
cerr<<"open camera fail"<<endl;
return -1;
}
int wh_rate_int = 37;// need to /10
all_p.gaus_size = test_vision.gaus_size_;
all_p.channel_idx = test_vision.channel_idx_;
all_p.grad_thre = test_vision.grad_thre_;
all_p.area_thre = test_vision.area_thre_;
all_p.wh_rate_thre = test_vision.wh_rate_thre_;
cv::namedWindow("set_params", CV_WINDOW_NORMAL);
cv::createTrackbar("gaus_size", "set_params", &all_p.gaus_size, 17);
cv::createTrackbar("channel_idx", "set_params", &all_p.channel_idx, 5);
cv::createTrackbar("grad_thre", "set_params", &all_p.grad_thre, 255);
cv::createTrackbar("area_thre", "set_params", &all_p.area_thre, 1000);
cv::createTrackbar("wh_rate", "set_params", &wh_rate_int, 120);
while (1) {
cp >> frame;
if (frame.empty()) {
cerr<<"frame empty"<<endl;
return -1;
}
#ifdef RUN_ON_DARWIN
cv::flip(frame, frame, -1);
cv::resize(frame, frame, cv::Size(320, 240));
#endif
all_p.wh_rate_thre = wh_rate_int/10.0;
test_vision.set_all_parameters(all_p);
test_vision.imageProcess(frame, &gabage);
char key = cv::waitKey(1);
if (key == 's') {
test_vision.StoreParameters();
break;
}
else if (key == 'q') {
break;
}
}
return 0;
}