opencv-write avi video file

Source: Internet
Author: User

#include <cv.h>#includeintMainintargcChar**argv) {Cvcapture* Capture =NULL; Capture= Cvcreatefilecapture ("Red moving China Design Network video material 2185.avi"); if(!capture)return-1; //get the first frame of the video and coexist in Bgr_frameIplimage *bgr_frame =Cvqueryframe (Capture); //get the total number of frames in a video cv_cap_prop_fps frame rate    Doublefps =Cvgetcaptureproperty (Capture, Cv_cap_prop_fps); //Get the height and width of the original videoCvsize size = Cvsize ((int) Cvgetcaptureproperty (Capture, Cv_cap_prop_frame_width), (int) Cvgetcaptureproperty (Capture, cv_cap_prop_frame_height)); ///Create a video file parameter representing the new video's name, respectively. Video compression encoding format new video frame rate new video image sizeCvvideowriter *writer = Cvcreatevideowriter ("1ai.avi", CV_FOURCC ('M','J','P','G'), FPS, size); //Create a first address and allocate storage spaceiplimage* logpolar_frame = cvcreateimage (size, ipl_depth_8u,3); //get the next frame of a video     while((Bgr_frame = Cvqueryframe (capture))! =NULL) {        //transferring video from Cartesian coordinate system to polar coordinate system parameter indicates input image output Image Transform Center scale parameter fill output image all parameters + Cv_inter_linear denotes bilinear parameter value (specifically what meaning)Cvlogpolar (Bgr_frame, Logpolar_frame, cvpoint2d32f (Bgr_frame->width/2, Bgr_frame->height/2), the, Cv_inter_linear +cv_warp_fill_outliers); //Save the retrieved frames from the Cartesian coordinate system to the new video fileCvwriteframe (writer, logpolar_frame); //The captured video is displayed through the Mainwin windowCvshowimage ("Mainwin", Logpolar_frame); Charc = Cvwaitkey ( -); //ESC exits by default        if(c = = -) Break; }    //free space requested in the programCvreleasevideowriter (&writer); Cvreleaseimage (&logpolar_frame); Cvreleasecapture (&capture); return(0);}

opencv-write avi video file

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.