-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.cpp
56 lines (41 loc) · 1.15 KB
/
main.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
45
46
47
48
49
50
51
52
53
54
55
56
#include <iostream>
#include "opencv2/opencv.hpp"
using namespace std;
using namespace cv;
int main() {
int cameraNumber(0);
string directory = "";
int savingFrames;
int i(-2);
std::cout << "What's your choice bitch " << std::endl;
cin >> cameraNumber;
cout << "Are you willing to save camera frames ? YES == 1 NO == 0 : "
cin >> savingFrames;
if (savingFrames)
{
cout << "Where to store images : ";
cin >> directory;
cout << "ok " << endl;
}
std::cout << "Camera used is : " <<cameraNumber << std::endl;
cv::VideoCapture cap(cameraNumber);
cap.set(CV_CAP_PROP_FRAME_WIDTH, 1280);
cap.set(CV_CAP_PROP_FRAME_HEIGHT, 960);
while (true) {
cv::Mat tmpImg;
cap.read(tmpImg);
cv::Mat new_image;
cv::cvtColor(tmpImg, new_image, COLOR_BGR2GRAY);
++i;
cv::imshow("LOL", new_image);
if (savingFrames)
{
string name = directory + std::to_string(i) + ".jpg";
cv::imwrite(name, new_image);
}
char c = (char) cv::waitKey(25);
if (c == 27)
break;
}
return 0;
}