Convert video sequence to Image Sequence

Source: Internet
Author: User

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;}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.