-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCameraCapture.cpp
More file actions
35 lines (32 loc) · 815 Bytes
/
CameraCapture.cpp
File metadata and controls
35 lines (32 loc) · 815 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
#include <opencv2/opencv.hpp>
#include <opencv2/core.hpp>
#include <opencv2/videoio.hpp>
#include <opencv2/highgui.hpp>
#include <stdio.h>
#include <iostream>
int main(int argc, char** argv) {
cv::VideoCapture cap;
int deviceID = 0;
int apiID = cv::CAP_ANY;
cap.open(deviceID, apiID);
if (!cap.isOpened()) {
std::cerr << "ERROR! Unable to open camera" << std::endl;
return -1;
}
cv::namedWindow("Video", 720);
cv::Mat frame;
while (true) {
cap.read(frame);
if (frame.empty()) {
std::cerr << "ERROR! blank frame grabbed" << std::endl;
break;
}
cv::imshow("Live", frame);
if (cv::waitKey(30) >= 0) {
break;
}
}
cap.release();
cv::destroyAllWindows();
return 0;
}