// opencv_1.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <OpenCV245.h>
#include <string>
using namespace std;
using namespace cv;
int _tmain(int argc, _TCHAR* argv[])
{
const string strFilePath = "C:\\Users\\sony\\Desktop\\video\\bike.avi";
VideoCapture cap;
Mat frame;
int frmNum = 0;
char _path[255];
char prefix[] = "C:\\Users\\sony\\Desktop\\p\\";
char postfix[] = ".jpg";
cap.open(strFilePath);
if (!cap.isOpened())
{
cout << "fail to open the video"<<endl;
return -1;
}
for (;;)
{
frmNum++;
cap>>frame;
if (frame.empty())
{
cout<<"video over"<<endl;
return -1;
}
memset(_path, '\0', sizeof(char)*255);
sprintf_s(_path, "%sframe_%04d%s",prefix,frmNum,postfix);
imwrite(_path,frame);
imshow("video",frame);
waitKey(250);
}
waitKey(0);
return 0;
}
将视频分解成帧保存
最新推荐文章于 2023-03-24 16:03:02 发布