Error opening file (/home/vaibhav/opencv/modul

2020-02-26 02:00发布

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)

标签: opencv
8条回答
家丑人穷心不美
2楼-- · 2020-02-26 02:05

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 );
查看更多
ら.Afraid
3楼-- · 2020-02-26 02:07

I'm facing the same issue, but the problem is I used the wrong resolution.

change

rtsp://admin:admin@192.168.1.58:554/h264/video.sdp?camera=13

to default solved it. (without indicating the resolution parameter)

rtsp://admin:admin@192.168.1.58:554/h264/video.sdp

BTW Device: EVO-05 Mini

查看更多
混吃等死
4楼-- · 2020-02-26 02:09

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

查看更多
5楼-- · 2020-02-26 02:14

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");

查看更多
别忘想泡老子
6楼-- · 2020-02-26 02:19

After having the same issue, I added one more header, opencv/ml.h, which is for machine learning. With this header and the Path variable C:\opencv\sources\3rdparty\ffmpeg\ your code works on my machine.

查看更多
何必那么认真
7楼-- · 2020-02-26 02:25

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:

C:\opencv\sources\3rdparty\ffmpeg\

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:

video_capture = cv2.VideoCapture ('C:\Temp\\bouncingBall.avi')

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:

https://docs.python.org/2.0/ref/strings.html

Hence the double backslash.

Anyway, hope this helps!

查看更多
登录 后发表回答