介绍:利用opencv,把视频分割成一帧帧图片,方便分析视频
代码:
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
CvCapture *capture = cvCreateFileCapture("D:\\video3.avi");
IplImage *frame;
frame = cvQueryFrame(capture);
int num = 0;
while (frame != NULL)
{
String path = "D:\\video3\\31_" + to_string(num) + ".jpg";
char p[50];
for (int i = 0; i < path.length(); i++)
p[i] = path[i];
cvSaveImage(p,frame,0);
num++;
frame = cvQueryFrame(capture);
}
}