-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample_collector.cpp
44 lines (38 loc) · 1.08 KB
/
sample_collector.cpp
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
#include <opencv2/opencv.hpp>
#include <raspicam_cv.h>
#include <iostream>
using namespace std;
using namespace cv;
using namespace raspicam;
Mat frame;
void Setup ( int argc,char **argv, RaspiCam_Cv &Camera )
{
Camera.set ( CAP_PROP_FRAME_WIDTH, ( "-w",argc,argv,400 ) );
Camera.set ( CAP_PROP_FRAME_HEIGHT, ( "-h",argc,argv,240 ) );
Camera.set ( CAP_PROP_BRIGHTNESS, ( "-br",argc,argv,50 ) );
Camera.set ( CAP_PROP_CONTRAST ,( "-co",argc,argv,50 ) );
Camera.set ( CAP_PROP_SATURATION, ( "-sa",argc,argv,50 ) );
Camera.set ( CAP_PROP_GAIN, ( "-g",argc,argv ,50 ) );
Camera.set ( CAP_PROP_FPS, ( "-fps",argc,argv,10));
}
int main(int argc,char **argv)
{
RaspiCam_Cv Camera;
Setup(argc, argv, Camera);
cout<<"Connecting to camera"<<endl;
if(!Camera.open())
{ cout<<"Failed to connect"<<endl;
return -1;
}
cout<<"Camera ID:-"<<Camera.getId()<<endl;
for(int i=0;i<300;i++)
{
Camera.grab();
Camera.retrieve(frame);
cvtColor(frame,frame,COLOR_BGR2GRAY);
imshow("Sample",frame);
imwrite("Stop"+to_string(i)+".jpg",frame);
waitKey();
}
return 0;
}