Runnable jars and opencv on a Raspberry Pi

Howdy all,

We are working on getting our vision processing code working with our robot but we have run into a little snag. We are planning on using a Raspberry Pi 3 to do the vision work to take the load off of the Rio, and the code seems to run well in eclipse. The issue is when we try to export the code as a runnable jar.

When we try to run this command with the jar:

java -Djava.library.path=~/Desktop/test_export_lib/ -jar test_export.jar

we get the following error:

Exception in thread “main” java.lang.UnsatisfiedLinkError: no opencv_java310 in java.library.path
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1857)
at java.lang.Runtime.loadLibrary0(Runtime.java:870)
at java.lang.System.loadLibrary(System.java:1119)
at HighGoalLightCV.<clinit>(HighGoalLightCV.java:38)

The contents of test_export_lib contains the opencv_310.jar file along with the other jars we are using. Looking online in multiple location mentioned something about a so or dll file (though the dll should only be for windows) which doesn’t seem to exist even after building the java version of opencv natively.

If anyone else has gotten their opencv code to run on a Pi any tipe would be greatly appreciated!

Did you ever figure this out or find another method?

I think the file you were missing would be “libopencv_java310.so”. We used the JavaGradle kit provided at https://github.com/wpilibsuite/VisionBuildSamples/releases as a starting point and it includes this file as part of the output.