In video processing, you often need to convert the video sequence. On the one hand, it is for convenience of processing, and on the other hand it is also a requirement of the project. If you want to convert a video sequence to an image frame, you can perform necessary pre-processing for the image sequence, such as tagging and extracting prior information. Here we use a simple video in the opencv platform library to convert an input video sequence to an image sequence program.
int _tmain(int argc, _TCHAR* argv[]){const string strFilePath="D:\\testVideo\\person.avi"; VideoCapture cap;Mat frame;int frmNum = 0;char _path[255];char prefix[]="D:\\images\\";char postfix[]=".jpg";cap.open(strFilePath);if( !cap.isOpened() ){ printf("can not open camera or video file\n"); return -1;}for (;;){ frmNum++; cap>>frame; if (frame.empty()) { printf("Video File Finished !\n"); return -1; } memset(_path,'\0',sizeof(char)*255); sprintf(_path,"%sframe_%04d%s",prefix,frmNum,postfix); imwrite(_path,frame); imshow("video",frame); waitKey(10); } printf("Video File Finished !\n"); system("pause"); return 0;}