Ask Your Question
0

Error -Converting a color video to grayscale ?

asked 2014-01-05 06:34:22 -0600

Parthi gravatar image

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?

edit retag flag offensive close merge delete

Comments

it means, that it could not find/load your video file.

(the error is thrown from cap_ffmpeg_impl.hpp, but i must admit, that this is pretty confusing)

berak gravatar imageberak ( 2014-01-05 08:19:01 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-01-05 07:52:15 -0600

unxnut gravatar image

You can remove the line

#include <opencv2\highgui\highgui_c.h>

It seems that you will be better off specifying the include files contained in the directory opencv2. You will need to find where your opencv2 headers are installed and specify that in the C++ settings in Project->Properties. You should also specify the include files correctly, such as

#include <opencv2/highgui/highgui.hpp>

Same with the other include files.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2014-01-05 06:34:22 -0600

Seen: 1,504 times

Last updated: Jan 05 '14