Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

java opencv Helloworld - how?

I really am missing something.

I can build opencv on my raspberry pi, and end up with opencv-XXX.jar and libopencv_javaXXX.so in /usr/local/share/OpenCV/java/

Great! I believe the so file is statically linked because i set BUILD_SHARED_LIBS=OFF in my cmake command, however, I did note in the cmake output it does say "Link libraries: Dynamic load"

My Helloworld.java program looks like this:

  import org.opencv.core.*;

  class HelloWorld {
    static {
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
    }
     public static void main(String[] args) {
        System.out.println("hello.");
    }
  }

I can compile this when I put the jar file in the classpath using "javac -cp /usr.../opencv-XXX.ar HelloWorld.java" but when I run it after (successfully) putting the .so file in the LD_LIBRARY_PATH, I get:

 Segmentation fault

It does it with 4.1.0, 4.0.0, and 3.4.1 and is obviously something I am not doing right.

Help!