Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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?

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.