-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstereo.cpp
More file actions
49 lines (45 loc) · 1.61 KB
/
stereo.cpp
File metadata and controls
49 lines (45 loc) · 1.61 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
//#include"Config.h"
#include<iomanip>
#include<opencv2/highgui/highgui.hpp>
#include<opencv2/opencv.hpp>
using namespace cv;
using namespace std;
int main() {
VideoCapture capr(0), capl(1);
//reduce frame size
capl.set(CV_CAP_PROP_FRAME_HEIGHT, 240);
capl.set(CV_CAP_PROP_FRAME_WIDTH, 320);
capr.set(CV_CAP_PROP_FRAME_HEIGHT, 240);
capr.set(CV_CAP_PROP_FRAME_WIDTH, 320);
namedWindow("Left");
namedWindow("Right");
cout << "Press 'c' to capture ..." << endl;
char choice = 'z';
int count = 0;
while(choice != 'q') {
//grab frames quickly in succession
capl.grab();
capr.grab();
//execute the heavier decoding operations
Mat framel, framer;
capl.retrieve(framel);
capr.retrieve(framer);
if(framel.empty() || framer.empty()) break;
imshow("Left", framel);
imshow("Right", framer);
if(choice == 'c') {
//save files at proper locations if user presses 'c'
stringstream l_name, r_name;
l_name << "left" << setw(4) << setfill('0') << count << ".jpg";
r_name << "right" << setw(4) << setfill('0') << count << ".jpg";
imwrite(string("/home/shaggy/line_auv/") + l_name.str(), framel);
imwrite(string("/home/shaggy/line_auv/") + r_name.str(), framer);
cout << "Saved set " << count << endl;
count++;
}
choice = char(waitKey(1));
}
capl.release();
capr.release();
return 0;
}