"Explore OpenCV" OpenCV Read video files

Source: Internet
Author: User

OpenCV need to do before reading a video file:

1. Download the video Codec

Recommended XviD, download link: http://pan.baidu.com/s/1jGjE2ii Password: xrni

2. Use the format factory to convert the video file to a standard format, such as *.avi

/*----------------------------------------OPENCV Video Read code---------------------------------------------*/

CString Filepath;    CFileDialog dlg (TRUE); if(DLG. DoModal () = =IDOK) {Filepath=dlg.    GetPathName (); }    Char*path; Path=Filepath.getbuffer (Filepath.getlength ()); Cvcapture*cap; Iplimage*frame; Const CharESC = -; Cvnamedwindow ("Camera", cv_window_autosize); if(Cap =cvcreatefilecapture (path)) {          while(frame = cvqueryframe (CAP))! =0&&Cvwaitkey ( -) !=ESC) {Frame=cvqueryframe (CAP); Cvshowimage ("Camera", frame); } cvreleasecapture (&cap); /*cvreleaseimage (&frame); * Note that this cannot be released, the release will be wrong*/Cvdestroywindow ("Camera"); }

Ps:

"Explore OpenCV" OpenCV Read video files

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.