-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtutorial.cpp
More file actions
47 lines (35 loc) · 1.13 KB
/
tutorial.cpp
File metadata and controls
47 lines (35 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
#include <iostream>
#include <opencv2/opencv.hpp>
using namespace std;
using namespace cv;
int main(int argc, char** argv) {
// Load the video file
VideoCapture cap("/Users/macbookpro/Desktop/UTEC/OpenCV/opencv3test/Resources/test_video.mp4");
// Check if the video file was opened successfully
if (!cap.isOpened()) {
cerr << "Error: could not open video file" << endl;
return -1;
}
// Create a window to display the video frames
namedWindow("Video", WINDOW_NORMAL);
// Loop over the video frames and display them in the window
while (true) {
// Read the next frame from the video file
Mat frame;
cap.read(frame);
// Check if the frame was read successfully
if (frame.empty()) {
break;
}
// Display the current frame in the window
imshow("Video", frame);
// Wait for a key press (or 30 milliseconds) to allow the frame to be displayed
if (waitKey(30) >= 0) {
break;
}
}
// Release the video file and destroy the window
cap.release();
destroyAllWindows();
return 0;
}