1

I want to execute a simple OpenCV code to test that the library is well loaded by Maven.

This is the code:

package helloworld;
import org.opencv.core.*;

public class Hello {

    public static void main(String[] args) 
    {
        nu.pattern.OpenCV.loadLibrary();
        System.out.println("Hey World !");
        Mat mat = Mat.eye(3, 3, CvType.CV_8UC1);
    }
}

And this is the console output I get, with the two errors, when I try to run it:

java.lang.NoSuchFieldException: sys_paths at java.base/java.lang.Class.getDeclaredField(Class.java:2417) at nu.pattern.OpenCV.loadLibrary(OpenCV.java:207) at helloworld.Hello.main(Hello.java:9)

Hey World !

Exception in thread "main" java.lang.UnsatisfiedLinkError: org.opencv.core.Mat.n_eye(III)J at org.opencv.core.Mat.n_eye(Native Method) at org.opencv.core.Mat.eye(Mat.java:1467) at helloworld.Hello.main(Hello.java:11)

I got the maven repository linking looking at that post.

Would you have any idea about what is causing that?

Thanks!

1 Answer 1

2

Try downloading a library from another repository.

<dependency>
    <groupId>org.openpnp</groupId>
    <artifactId>opencv</artifactId>
    <version>3.4.2-1</version>
</dependency>

You can see my answer to the post with a similar problem.

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you for answering, but I "resolved" my problem changing the dependency as you did, and with nu.pattern.OpenCV.loadLocally(); but every tiime I launch the program the error "You have loaded library /tmp/opencv_openpnp.../libopencv_java342.so which might have disabled stack guard. The VM will try to fix the stack guard now. It's highly recommended that you fix the library with 'execstack -c <libfile>', or link it with '-z noexecstack'."
Run this command: execstack -c /tmp/opencv_openpnp.../libopencv_java342.so. This should help

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.