#include <opencv2/opencv.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main(int argc, char** argv) {
VideoCapture capture; //一个视频读取函数capture
capture.open("L:/opencv_picture/video_004.avi"); // capture.open读取视频文件位置
if (!capture.isOpened()) {
printf("could not load video data...\n"); //如果读不到视频
return -1;
}
Mat frame; //一帧图像frame
namedWindow("video-demo", CV_WINDOW_AUTOSIZE);
while (capture.read(frame)) { //capture.read读取视频后将每一帧图像放在frame中
imshow("video-demo", frame); //显示每一帧图像
char c = waitKey(50); //每帧延时0.05秒
if (c == 27) { //如果按下Esc键
break;
}
}
waitKey(0);
return 0;
}