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)
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.:
I'm facing the same issue, but the problem is I used the wrong resolution.
change
to default solved it. (without indicating the resolution parameter)
BTW Device: EVO-05 Mini
If using absolute path, add double slash to path as below.
I also got the same error if the video is not present in the folder. So, just put the video at a place where you don't need to give a long path which you are doing currently (just to see that your program can work). For example, i have placed my video just outside the "source folder", so i just write
capture = cvCreateFileCapture("video.avi");
After having the same issue, I added one more header,
opencv/ml.h
, which is for machine learning. With this header and the Path variableC:\opencv\sources\3rdparty\ffmpeg\
your code works on my machine.I had the same problem, and I did two things (I'm using Python 2.7.9 on Windows 10):
First, add this folder to your Path variable:
And this file
opencv_ffmpeg300.dll
must have the correct OpenCV version. For example, for me it's 3.0.0, so you need to change it for yourself.Next, make sure to add an extra backslash slash in your video path:
Python has some special characters, so if there's only one backslash, it would interpret it differently and thus throw an error. You can see more here:
Hence the double backslash.
Anyway, hope this helps!