Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error opening file (/home/vaibhav/opencv/modules/highgui/src/cap_ffmpeg_impl.hpp:553) in openCV

Tags:

opencv

I am using OpenCV to display a video my code is as

#include<opencv2/highgui.hpp>
#include<cv.h>
#include<opencv/cv.hpp>
#include<opencv2/opencv.hpp>
#include<cvaux.h>
#include<cxcore.h>
#include<stdio.h>
#include<highgui.h>
#include<stdlib.h>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <iostream>

using namespace cv;
int main( int argc, char ** argv )
{
CvCapture* capture;
cvNamedWindow( "video", CV_WINDOW_AUTOSIZE ); 
capture = cvCreateFileCapture("/home/vaibhav/program/c/w.avi");
IplImage* frame;
while(1){
frame = cvQueryFrame( capture );
if( !frame ) break;
cvShowImage( "video", frame );
char c = cvWaitKey(33);
if( c == 27 ) break;
}

cvReleaseCapture( &capture );

cvDestroyWindow( "Webcam" );

return 0; }

The program compiles but it gives error when try to run it

I am using Ubuntu 12.04 and Eclipse

warning: Error opening file (/home/vaibhav/opencv/modules/highgui/src/cap_ffmpeg_impl.hpp:553)
like image 247
user3309272 Avatar asked Feb 14 '14 08:02

user3309272


3 Answers

to clear up some confusion here:

the error means, that it could not find or open your Video file. (either file not found, or codec not present)

"/home/vaibhav/opencv/modules/highgui/src/cap_ffmpeg_impl.hpp:553" is just the location of the code, where the error is thrown.

(and please, don't use the deprecated c-api any longer, they stopped developing it like 5 years ago, switch over to the c++ one. )

like image 79
berak Avatar answered Oct 10 '22 00:10

berak


I had the same problem. Very annoying (opencv 2.4.9). But what worked for me was passing the absolute file name (avi or mpeg), i.e whole path.

E.g.:

char* fileName = "D:/myVideos/video.avi"
...
VideoCapture capture(fileName );
like image 26
mykey Avatar answered Oct 10 '22 01:10

mykey


If using absolute path, add double slash to path as below.

data = cv2.VideoCapture('C:\Data\MyVideo.mp4')

data.isOpened()

Out[11]: False

data = cv2.VideoCapture('C:\\\Data\\\MyVideo.mp4')

data.isOpened()

Out[13]: True

like image 27
user4963156 Avatar answered Oct 10 '22 01:10

user4963156