-
Notifications
You must be signed in to change notification settings - Fork 903
/
example_02-03.cpp
58 lines (40 loc) · 1.05 KB
/
example_02-03.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
57
58
// Example 2-3. A simple OpenCV program for playing a video file from disk
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
using namespace std;
void help(char** argv ) {
std::cout << "\n"
<< "2-03: play video from disk \n"
<< argv[0] <<" <path/video>\n"
<< "For example:\n"
<< argv[0] << " ../tree.avi\n"
<< std::endl;
}
int main( int argc, char** argv ) {
if (argc != 2) {
help(argv);
return 0;
}
cv::namedWindow( "Example 2-3", cv::WINDOW_AUTOSIZE );
cv::VideoCapture cap;
cap.open( string(argv[1]) );
cout <<"Opened file: " <<argv[1] <<endl;
cv::Mat frame;
for(;;) {
cap >> frame;
if( frame.empty() ) break; // Ran out of film
cv::imshow( "Example 2-3", frame );
if( (char)cv::waitKey(33) >= 0 ) break;
// int c = cv::waitKey(33);
// for(int i=0;i<32;i++) {
// cout <<((c&(0x1<<(31-i)))?1:0);
// }
// cout <<endl;
// cout <<"Break key: '" <<(int)c <<"'"<<endl;
// if( (signed char)c >= 0 ) {
// break;
// }
}
return 0;
}