-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_cam.cpp
More file actions
37 lines (33 loc) · 727 Bytes
/
test_cam.cpp
File metadata and controls
37 lines (33 loc) · 727 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
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
VideoCapture stream1(0); //0 is the id of video device.0 if you have only one camera.
if (!stream1.isOpened())
{ //check if video device has been initialised
cout << "cannot open camera";
}
int i=0;
stringstream ss;
//unconditional loop
while (true)
{
Mat cameraFrame;
stream1.read(cameraFrame);
imshow("cam", cameraFrame);
//lines to save the capture image
ss<<"Photo_0000"<<i++<<".bmp";
string filename = ss.str();
imwrite(filename, cameraFrame);
ss.str(" ");
if (i>=10)
exit(1);
//
if (waitKey(30) >= 0)
break;
}
return 0;
}