-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathch1_2.cpp
More file actions
37 lines (34 loc) · 714 Bytes
/
ch1_2.cpp
File metadata and controls
37 lines (34 loc) · 714 Bytes
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
// please enter the dispaly window name
#include <iostream>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
int main(int argc, char * argv[])
{
VideoCapture cap(0);//open the default camera
if(!cap.isOpened())
{
cout<<"no camera detected\n";
return -1;
}
namedWindow(argv[1],WINDOW_AUTOSIZE);
Mat img;
int ct=0;
stringstream ss;
string name = "Photo_0000";
string type = ".jpg";
cout<<"in capture"<<endl;
for(int i=0;i<5;i++)
{
cap >> img; //get a new frame from camera
imshow(argv[1],img);
ss<<name<<i<<type;
string filename = ss.str();
ss.str(" ");
imwrite(filename, img);
//if(waitKey(30)>=0) break;
waitKey(0);
}
//waitKey(0);
return 0;
}