// video.cpp : Defines the entry point for the console application.
//convert a video to grayscale
//argv[1]: input video file
//argv[2]: name of new output file
#include <cv.h>
#include <cvaux.h>
#include <highgui.h>
#pragma comment(lib, "ml.lib")
#pragma comment(lib, "cv.lib")
#pragma comment(lib, "cvaux.lib")
#pragma comment(lib, "cvcam.lib")
#pragma comment(lib, "cxcore.lib")
#pragma comment(lib, "cxts.lib")
#pragma comment(lib, "highgui.lib")
#pragma comment(lib, "cvhaartraining.lib")
int main(int argc, char* argv[])
{
CvCapture* capture = 0;
capture = cvCreateFileCapture("D:\\clock.avi");
if(!capture)
{
return -1;
}
//init the video read
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(
"result.avi",
CV_FOURCC('M', 'J', 'P', 'G'),
fps,
size
);
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;
}
注:安装了K-Lite codec Pack,可以读文件,"result.avi“文件为0KB.未解决····
http://fileforum.betanews.com/download/KLite-Codec-Pack_Full/1094057842/3