读取视频帧图像

#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;
}

posted @ 2022-01-10 03:58  量子与太极  阅读(117)  评论(0编辑  收藏  举报