-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathCV-Sandbox.cpp
54 lines (40 loc) · 1.27 KB
/
CV-Sandbox.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
// CV-Sandbox.cpp : Defines the entry point for the application.
//
#include "CV-Sandbox.h"
#include "opencv2/opencv.hpp"
#include <iostream>
using namespace std;
using namespace cv;
int main() {
// Create a VideoCapture object and open the input file
// If the input is the web camera, pass 0 instead of the video file name
// Get an image name
std::string filename = MEDIA_DIRECTORY;
// MEDIA_DIRECTORY is defined in the root-level CMake script
filename += "CameraOrbit.MOV";
VideoCapture cap(filename);
// Check if camera opened successfully
if (!cap.isOpened()) {
cout << "Error opening video stream or file" << endl;
return -1;
}
while (1) {
Mat frame;
// Capture frame-by-frame
cap >> frame;
// If the frame is empty, break immediately
if (frame.empty())
break;
// Display the resulting frame
imshow("Frame", frame);
// Press ESC on keyboard to exit
char c = (char)waitKey(25);
if (c == 27)
break;
}
// When everything done, release the video capture object
cap.release();
// Closes all the frames
destroyAllWindows();
return 0;
}