#include<iostream>
#include<opencv2/opencv.hpp>
using namespace std;
using namespace cv;
void video2Image()
{
//VideoCapture cap("1.avi");
VideoCapture cap("F:/testImage/1/output_1.2_result.mp4");
// 获取视频总帧数
long totalFrameNumber = cap.get(CAP_PROP_FRAME_COUNT);
cout << "total frames: " << totalFrameNumber << endl;
Mat frame;
bool flags = true;
long currentFrame = 0;
while (flags) {
// 读取视频每一帧
cap.read(frame);
stringstream str;
str << "a2" << currentFrame << ".jpg";
cout << "正在处理第" << currentFrame << "帧" << endl;
printf("\n");
// 设置每30帧获取一次
C++OpenCV将视频处理成图像
最新推荐文章于 2024-07-11 10:34:15 发布
本文介绍如何利用C++和OpenCV库将视频文件拆分成一系列图像帧,详细解析了关键代码和步骤,适合对计算机视觉和C++编程有一定基础的读者。
摘要由CSDN通过智能技术生成