-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase_image.cpp
More file actions
77 lines (61 loc) · 1.7 KB
/
base_image.cpp
File metadata and controls
77 lines (61 loc) · 1.7 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<opencv2/opencv.hpp>
#include<opencv2/highgui/highgui.hpp>
#include<opencv2/imgproc/imgproc.hpp>
#include<iostream>
#include<sstream>
using namespace std;
using namespace cv;
int main()
{
VideoCapture cap(0);
//VideoCapture capf(0);
Mat src,src_f;
if ((!cap.isOpened())) // if not success, exit program
{
cout << "Cannot open the camera" << endl;
return -1;
}
int count=0,bases_required=600;
//int frame_width=600,frame_height=400;
while (1)
{
//Mat img, gr;
bool bSuccess1 = cap.read(src);
//bool bSuccess2 = capf.read(src_f);
if ((!bSuccess1))//||(!bSuccess2)) //if not success, break loop
{
cout << "Cannot read the frame from video file" << endl;
break;
}
imshow("down camera",src);
//imshow("front camera",src_f);
int start=waitKey(12);
//int stop=waitKey();
//++count;
//++count;
//VideoWriter out ( "out"+s+".avi",CV_FOURCC('M','J','P','G'),10, Size(frame_width,frame_height),true);
if(start>=50)
{
++count;
std::string s;
std::stringstream out;
out << count;
s = out.str();
// out.write(src);
imwrite(s+"b.jpg",src);
// imwrite(s+"f.jpg",src_f);
cout<<"image stored"<<"\n";
// bool bSuccessr = cap.read(src);
//start=waitKey(12);
}
/*else if(bases_required==count)
{
break;
}*/
else if( waitKey(10)==27)
break;
else
continue;
}
return 0;
}