java.lang.UnsatisfiedLinkError: org.opencv.core.Mat.n_Mat(III)J?

后端 未结 3 656
清酒与你
清酒与你 2021-01-14 12:31

I\'ve been trying to get opencv working inside of our raspberry pi, but I have not been able to get it working at all. I made a new eclipse project, added in the OpenCV libr

3条回答
  •  执笔经年
    2021-01-14 13:00

    You can load the library like this: first of all call this method

    public static void loadOpenCV_Lib() throws Exception {
        // get the model
        String model = System.getProperty("sun.arch.data.model");
        // the path the .dll lib location
        String libraryPath = "C:/opencv/build/java/x86/";
        // check for if system is 64 or 32
        if(model.equals("64")) {
            libraryPath = "C:/opencv/build/java/x64/";
        }
        // set the path
        System.setProperty("java.library.path", libraryPath);
        Field sysPath = ClassLoader.class.getDeclaredField("sys_paths");
        sysPath.setAccessible(true);
        sysPath.set(null, null);
        // load the lib
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
    }
    

    Note: In code above the OpenCV has extracted in C drive root folder.

    Edit: In Eclipse you are also can do it like this: Right click on the project -> Build Path -> Configure Build Path -> Libraries (Tab) -> Expend the OpenCV jar -> Native library location: -> Eidt -> Put this; C:/opencv/build/java/x64/ -> OK -> Apply...

提交回复
热议问题