I have a problem using VideoCapture class with OpenCV 2.4.2 under windows XP 32bits. It doesn\'t open any file or camera and fixing it\'s being a pain. Im using visual studi
See the fix I found below, for mp4 files. I faced the same issue on Windows 7, using OpenCV 2.4.9. I am using the java wrapper for opencv.
Matthias Krings has done a lot of research for this. See this. Apparently this is an issue based on the video file type. With .avi files, it seems to work for a lot of people. Unfortunately his solution of setting OPENCV_DIR did not work for me. But his comments in the bug listing gave me a hint to fix the issue.
You have to do two things:
java.library.path
to include the directory {opencv\install\dir}opencv-2.4.9\build\x86\vc10\bin
. You can set the variable using the -D
option on the java command line: java -Djava.library.path=PATH_TO_YOUR_DLL ...
. Also fetch this variable from your environment, using System.getProperty(...)
, and print it before calling loadLibrary()
, to verify that the path setting is working. System.loadLibrary("opencv_ffmpeg249");
. The loadLibrary()
function should be invoked from within a static block
in java. opencv_ffmpeg249.dll
in the java.library.path
that we set. .so
files.I also faced with this problem and solved it by correct the path of the function:
VideoCapture cap(videoName);
If the AVI file of videoName does't exist, it will be an error:
(../../modules/highgui/src/cap_ffmpeg_impl.hpp:XXX)
where XXX represents the line number.
In my case, the same problem was resolved after deleting all opencv_***.dll
files in C:\Windows\System32
. So, I use the dll files just through the path like "%PATH%;C: \Program Files \OpenCV2.4.2\build\x86\vc10/bin"
. Please try it.
I had the same issue with the open method whilst running under Windows 8 (64bit), opencv 2.4.10. IDE is running in x86.
I found that running the application in release configuration solved the problem.
Stumbled across the answer because I had the same issue with imread. Issue is presented in the this thread. imread not working in Opencv
I too faced the same issue and resolved after pointing to the correct location of the input video.