赞
踩
ref:https://blog.csdn.net/qq_37716188/article/details/109057659
- #include <iostream>
- #include <string>
- #include <opencv2/opencv.hpp>
-
- using namespace std;
- using namespace cv;
-
- #define interval 4 //修改这里以改变多久保存一帧
- int main()
- {
- VideoCapture capture("./video/video1.mp4");
- if (!capture.isOpened()){
- return -1;
- }
- int imgIndex = 0;
-
- Mat frame;
- capture >> frame;
- while (!frame.empty()) {
-
- string output = "./video/image/" + to_string(imgIndex) + ".jpg";
-
- if (imgIndex % interval == 0) {
- //第一个参数是写入的文件名,第二个参数是Mat类型的图像数据。
- imwrite(output, frame);
- }
-
- imgIndex++;
- capture >> frame;
- }
-
- return 0;
- }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。