Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Error -Converting a color video to grayscale ?

hi guys,

I am using win7-32bit and Visual Studio 2012 professional .While I am executing an example from Learning opencv book.here is the source code

#include <opencv\cv.h>
#include <opencv\cxcore.h>
#include <opencv\highgui.h>
#include <opencv2\highgui\highgui_c.h>
#include<iostream>

 int main(int argc,char** argv)
 {
CvCapture* capture=0;
capture=cvCreateFileCapture(argv[1]);
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(argv[2],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);
    printf("wait");
}
printf("finished");
    cvReleaseVideoWriter(&writer);
cvReleaseImage(&logpolar_frame);
cvReleaseCapture(&capture);
return 0;
   }

Commandline arguments:

logpolor.exe Mun.avi mun.mpeg

after building, I get this this error during execution

warning error opening file (../../modules/highgui/src/cap_ffmpeg_impl.hpp:545

What should I change? every other program works fine?