#include <iostream>
#include "cv.h"
#include "opencv2/opencv.hpp"
using namespace std;
using namespace cv;
void main()
{
//获取视频文件
VideoCapture cap("C:\\Users\\dell\\Desktop\\video2019-07-15 15_03_23.avi");
/*IplImage *nFrames = NULL;
CvCapture* pCapture = NULL;
if (!(pCapture = cvCaptureFromAVI("C:\\Users\\dell\\Desktop\\video2019-07-15 15_03_23.avi")))
{
fprintf(stderr, "Can not open camera.\n");
return ;
}
int numFrames = (int)cvGetCaptureProperty(pCapture, CV_CAP_PROP_FRAME_COUNT);
printf("nums = %d", numFrames);*///查看原视频总帧数
// 获取视频总帧数
long totalFrameNumber = cap.get(CV_CAP_PROP_FRAME_COUNT);
cout << "total frames: " << totalFrameNumber << endl;
Mat frame;
bool flags = true;
long currentFrame = 0;
while (flags){
// 读取视频每一帧
cap.read(frame);
cout << "正在处理第" << currentFrame << "帧" << endl;
printf("\n");
// 设置每30帧获取一次帧
if (currentFrame % 25 ==
VS-opencv 将视频按帧截取成图片
最新推荐文章于 2025-06-26 19:06:08 发布