0
点赞
收藏
分享

微信扫一扫

OpenCV循环读取视频



#include<opencv2/opencv.hpp>

using namespace std;
using namespace cv;

int main()
{
VideoCapture capture("car.mp4");
if (!capture.isOpened())
cout << "fail to open!!!" << endl;
int totalFrames = capture.get(CV_CAP_PROP_FRAME_COUNT);
int currentFrames = 0;
while (1)
{
Mat frame;
capture >> frame;
resize(frame, frame, Size(1280, 960));
if (currentFrames == totalFrames - 1)
{
currentFrames = 0;
capture.set(CV_CAP_PROP_POS_FRAMES, 0);
}
imshow("car", frame);
currentFrames++;
waitKey(35);
}
return 0;
}

更多《计算机视觉与图形学》知识,可关注下方公众号:计算机视觉与图形学实战


举报

相关推荐

0 条评论