直接code
#include <iostream>
#include "cv.h"
#include "opencv2/opencv.hpp"
using namespace std;
using namespace cv;
void main()
{
string VideoPath;
VideoCapture cap("../1.mp4");
double 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);
stringstream str;
str << currentFrame << ".jpg";
cout << "正在处理第" << currentFrame << "帧" << endl;
if (currentFrame % 1 == 0)
{
imwrite("../image2/" + str.str(), frame);
}
if (currentFrame >= totalFrameNumber)
{
flags = false;
}
currentFrame++;
}
system("pause");
}