#include<opencv2/opencv.hpp>
#include<iostream>
using namespace std;
using namespace cv;
#define interval 4 //修改这里以改变多久保存一帧
int main()
{
VideoCapture capture("E:/ship/200/kejian.mp4");
if (!capture.isOpened()) {
return -1;
}
int imgIndex = 0;
int i = 1;
Mat frame;
//capture.set(CAP_PROP_FRAME_WIDTH, 640);
//capture.set(CAP_PROP_FRAME_HEIGHT, 512);
capture >> frame;
while (!frame.empty()) {
string output = "E:/kejian/" + to_string(i) + ".jpg";
if (imgIndex % interval == 0) {
resize(frame, frame, Size(640, 512), INTER_LINEAR);//设置帧尺寸
//第一个参数是写入的文件名,第二个参数是Mat类型的图像数据。
imwrite(output, frame);
}
i++;
capture >> frame;
}
return 0;
}