-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcamtest.cpp
More file actions
49 lines (39 loc) · 1.13 KB
/
Copy pathcamtest.cpp
File metadata and controls
49 lines (39 loc) · 1.13 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
/* To Compile camtest.cpp and create executable camtest:
g++ -O2 `pkg-config --cflags --libs opencv` camtest.cpp -o camtest
To run:
./camtest
*/
#include <iostream>
#include <stdio.h>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
#define WIDTH 320
#define HEIGHT 240
double width = 320;
double height = 240;
double im_width;
double im_height;
int main(){
VideoCapture capture(-1);
capture.set(CV_CAP_PROP_FRAME_WIDTH,width);
capture.set(CV_CAP_PROP_FRAME_HEIGHT,height);
im_width = capture.get(CV_CAP_PROP_FRAME_WIDTH);
im_height = capture.get(CV_CAP_PROP_FRAME_HEIGHT);
printf("Setup completed\n");
Mat imgBGR;
if(!capture.isOpened()){
cout << "Camera not Working" << endl;
}
capture >> imgBGR;
printf("Captured image\n");
vector<Mat> bgr;
split(imgBGR,bgr);
printf("Split image into components\n");
imwrite("imgB.png",bgr[0]);
imwrite("imgG.png",bgr[1]);
imwrite("imgR.png",bgr[2]);
imwrite("img.png",imgBGR);
printf("Wrote images\n");
return 0;
}