0

The Java example provided with OpenCV called HelloCV doesn't work. This is the example:

import org.opencv.core.Core;
import org.opencv.core.CvType;
import org.opencv.core.Mat;

public class Main {

    public static void main(String[] args) {
        System.out.println("Welcome to OpenCV " + Core.VERSION);
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);
        Mat m  = Mat.eye(3, 3, CvType.CV_8UC1);
        System.out.println("m = " + m.dump());
    }

}

The output throws UnsatisfiedLinkError, what is this error and how do I solve it. I had to build the OpenCV jar file, I thought I did it correctly but I could have done something wrong when building the library.

1 Answer 1

0

EDIT 1: I just found this question and it has an answer with a better solution. I'm going to try it since it looks more elegant.


Are you using Maven? I had the same problem with Java + Maven. It couldn't find the OpenCV library, so I bypassed this problem by putting the libopencv_java249.so (in my case) in the root directory of the project and loaded it with the following code:

private static void loadOpenCV() throws IOException {
    File curDir = new File(".");
    System.load(curDir.getCanonicalPath() + "/libopencv_java249.so");
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.