色彩视频文件转换为灰度格式

// 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 "stdafx.h"
#include "cv.h"
#include "highgui.h"


int main(int argc, char* argv[])
{
CvCapture* capture = 0;
capture = cvCreateFileCapture("Pan_Stab_New Border_11_ 9.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.未解决····

你可能感兴趣的:(video,null,input,border,output,Codec)