读取本地视频,获取前50帧的图像并保存图片
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <iostream>
using namespace std;
using namespace cv;
int main()
{
//Open video
VideoCapture capture("C:\\Users\\10985\\source\\repos\\CVDemo01\\video.mp4");
//Check whether it is opened normally: when successfully opened, isOpened returns true
if (!capture.isOpened())
cout << "Video reading error !" << endl;
//Set start frame()
int frameToStart = 1;
capture.set(CV_CAP_PROP_POS_FRAMES, frameToStart);
int frameToStop = 50;
//Carry the image of each frame
Mat frame;
//Use while loop to read frames
//currentFrame is a variable that controls the end of the loop after reading the specified frame in the loop body
int currentFrame = frameToStart;
w