Ask Your Question

Phil's profile - activity

2018-05-10 18:03:43 -0600 received badge  Popular Question (source)
2016-08-05 03:34:26 -0600 received badge  Self-Learner (source)
2014-10-29 10:26:50 -0600 answered a question Java: VideoCapture cannot open file

Problem was the windows path variable. Can be set in the environment tab in the run configuration in Eclipse. (I set it to E:\opencv\opencv\build\x64\vc12\bin)

2014-10-24 21:06:14 -0600 received badge  Editor (source)
2014-10-24 21:03:48 -0600 asked a question Java: VideoCapture cannot open file

I'm trying to extract a frame from a file. For the moment I'd be happy if any format would work, my goal is to apply my code to recorded webcam files (MJPEG).

I downloaded and extraced the binaries (opencv-2.4.10) on my Windows 7 x64 machine running Java JDK 1.7.0_21 (x64).

I'm using Eclipse and set it up: E:\opencv\opencv\build\java\opencv-2410.jar is in my classpath, the native path for that I tried E:\opencv\opencv\build\java\x64 and E:\opencv\opencv\build\x64\vc12\bin.

My code is:

    public void test() {
    System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
    String dir = "X:\\code\\workspace\\OpenCV-step1\\";
    String file = "MVI_0191.MOV";
    VideoCapture vc = new VideoCapture();

    if(vc.open(file)) {
        System.out.println("Success");
    } else {
        System.out.println("Failure");
    }
}

I tried reading a file I downloaded (https://code.ros.org/trac/opencv/export/2270/trunk/opencv/samples/c/tree.avi), a file off my camera (MOV) and a AVI (MJPEG) I recorded off my ip camera using VLC - none of them can be opened.

I can run the program but the output is always "Failure" / the file cannot be opened.

What is wrong with my setup?

I followed the documentation (http://docs.opencv.org/trunk/doc/tutorials/introduction/java_eclipse/java_eclipse.html) and can run the 3x3 example in there, but cannot open video files.