Ask Your Question
0

Java: VideoCapture cannot open file

asked 2014-10-24 21:03:48 -0600

Phil gravatar image

updated 2014-10-24 21:06:14 -0600

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.

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2014-10-29 10:26:50 -0600

Phil gravatar image

updated 2014-10-29 10:27:53 -0600

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)

edit flag offensive delete link more

Question Tools

Stats

Asked: 2014-10-24 21:03:48 -0600

Seen: 2,139 times

Last updated: Oct 29 '14