-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmodelfactorydataset.cpp
More file actions
42 lines (33 loc) · 1.16 KB
/
modelfactorydataset.cpp
File metadata and controls
42 lines (33 loc) · 1.16 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
#include <iostream>
#include "opencv2/opencv.hpp"
using namespace cv;
using namespace std;
int main(int argc, char** argv)
{
VideoCapture cap(0); // open the default camera
if(!cap.isOpened()) // check if we succeeded
return -1;
//Size winSize(50,50);
string model = "model factory";
namedWindow(model, 1);
int i = 0;
for(;;)
{
Mat frame, gray, image;
int *pt_i = &i;
cap >> frame; // get a new frame from camera
frame.copyTo(image);
//cvtColor(image, gray, COLOR_BGR2GRAY); //convert to gray
imshow(model, image); //show the image or gray image
char c =(char)waitKey(30); //wait 30ms for next frame
if( c == 's'){ //keypress s to take photos
char filename[100];
sprintf(filename,"/home/joseph/VOexamples/modelFactoryDataSet/0%d.png",*pt_i);
printf("write to file %d \n",*pt_i);
imwrite(filename, image); //write gray or image to filename
i++;
}
}
// the camera will be deinitialized automatically in VideoCapture destructor
return 0;
}