#include "Cv.h"
#include "highgui.h"
int main (int argc,char* argv[]) {//The main in the book is not defined as an int return type, error: C + + does not support int by default
cvcapture* capture = 0;
Capture = Cvcreatefilecapture ("P.avi"),//p.avi stored directly in the folder where the current CPP file is located, all without the write path, otherwise such as: D:\\sandy\\visual studio 2010\\ Projects\\video\\video\\p.avi
if (!capture) return-1;
Iplimage *bgr_frame = cvqueryframe (capture);
Double fps = cvgetcaptureproperty (capture, Cv_cap_prop_fps);
Cvsize size =cvsize (
(int) Cvgetcaptureproperty (capture,cv_cap_prop_frame_width),
(int) Cvgetcaptureproperty (capture,cv_cap_prop_frame_height)
);
Cvvideowriter *writer=cvcreatevideowriter ("D:\\shengcheng.avi", CV_FOURCC (' M ', ' J ', ' P ', ' G '), fps,size);//Cv_ FOURCC (' M ', ' J ', ' P ', ' G ') instead of-1, just generate a Shengcheng.avi file in D, and I don't understand why.
iplimage* logpolar_frame =cvcreateimage (size,ipl_depth_8u,3);
while ((Bgr_frame = Cvqueryframe (capture))!=null) {
Cvlogpolar (Bgr_frame,logpolar_frame,
cvpoint2d32f (BGR_FRAME->WIDTH/2,
BGR_FRAME->HEIGHT/2),
40,cv_inter_linear+cv_warp_fill_outliers);
Cvwriteframe (Writer,logpolar_frame);
}
Cvreleasevideowriter (&writer);
Cvreleaseimage (&logpolar_frame);
Cvreleasecapture (&capture);
return (0);
}
Original video:
Generate Video:
Implement read into a color video file and output this video file in grayscale format, learn OpenCV example 2-10