Created
May 6, 2017 02:16
-
-
Save miguelrochajr/98da3cfaf129207fa7f42a1380debaea to your computer and use it in GitHub Desktop.
How to Open a video file on OpenCV 3.1.0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <opencv2/highgui/highgui.hpp> | |
#include <opencv2/imgproc/imgproc.hpp> | |
#include <iostream> | |
int main() { | |
cv::VideoCapture cap; | |
cap.open("myVideo.mp4" ); | |
cv::namedWindow( "myVideo", cv::WINDOW_AUTOSIZE ); | |
cv::Mat frame; | |
while(true) { | |
cap >> frame; | |
if( frame.empty() ){ | |
std::cout << "Could not load the video frames. \n"; | |
break; | |
} | |
cv::imshow( "myVideo", frame ); | |
if( cv::waitKey(27) >= 0 ){ | |
std::cout << "Escape pressed \n"; | |
break; | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment