3

OpenCV 3.0 with Java cannot open video file, but it woks with camera. Before I was using OpenCV 3.0-beta it was working well in both, but in OpenCV 3.0 which is released on 2015-04-24 doesn't work with video file.

If anyone know about this problem of OpenCV 3, please tell me the reason and how to solve this.

Bahramdun Adil
  • 5,907
  • 7
  • 35
  • 68

3 Answers3

5

I solved my problem like this: Copy the C:\opencv\build\x64\vc12\bin to the system path and restart the Eclipse.

Hope this help someone that may has this problem with OpenCV 3.0.

Bahramdun Adil
  • 5,907
  • 7
  • 35
  • 68
  • Thanks! I was just getting an unhelpful "Couldn't open video file." message which made it seem like it wasn't finding video file. I added the path, and it worked. I guess it just wasn't finding the ffmpeg libs. Is there another error log somewhere that gives more info about problems like this? – medloh Oct 19 '15 at 00:39
  • You are welcome. No there is no more information about this error, usually OpenCV doesn't give more information when throwing some exception. And also I have a problem whit new version of OpenCV (3.0) which I cannot write Video, because there is no VideoWriter class in OpenCV Java bindings. Could you tell the solution how to write frames. Thanks – Bahramdun Adil Oct 20 '15 at 02:24
  • No, I have not tried writing frames, only reading frames from mp4 which works fine for me in Opencv 3.0. Sounds like that issue is probably worthy of a different stackoverflow question thread. – medloh Oct 20 '15 at 05:31
1

Even after adding C:\opencv\build\x64\vc12\bin to SYSTEM path, if you cannot open VideoCapture then you could also try coping opencv_ffmpegXXX_64.dll from opencv/build/java/x64 or from opencv\build\x64\vc14\bin. I don't know why this works but it worked for me after trying:

https://stackoverflow.com/a/29920295/677185 and https://github.com/opencv/opencv/issues/4974

vincent mathew
  • 4,278
  • 3
  • 27
  • 34
1

Generally opencv_ffmpegXXX.dll file not placed at opencvjavaXXX.dll file folder so you need to load two library in java code

You should have try this.

System.loadLibrary(Core.NATIVE_LIBRARY_NAME); // for OpencvjavaXXX.dll 

System.loadLibrary("opencv_ffmpeg320_64"); // for OpenCV_ffmpegXXX.dll file 

You can specify full DLL file path into the (string) parameter

xiawi
  • 1,772
  • 4
  • 19
  • 21
Ujash Patel
  • 21
  • 13