repo
I’m trying to use opencv with kotlin for a robotics project but since opencv doesn’t have a maven package for their library I have to use the jar file they have. I have included the jar file locally and added it via implementation(fileTree("vendor/"))
. Then in Main.kt I have System.loadLibrary(Core.NATIVE_LIBRARY_NAME)
and according to these files from team 401 that’s all I need to do. I am able to build and IDEA gives me completion for org.opencv
packages but when I try and run I get Exception in thread "main" java.lang.UnsatisfiedLinkError: no opencv_java455 in java.library.path
. From what I’ve read my best guess is that I need to somehow also link to the native libraries for opencv. So I tried and added it to the java.library.path
(tried with both shared and static AND tried adding lib
and .so/a
prefix/suffixes to Core.NATIVE_LIBRARY_NAME
) but still nothing. Even if that did work I’d be confused as to how the “team401” project worked since they only linked the jar file as far as I can tell. Also even if it did work would I have to cross compiling opencv for all the platforms I want to use it on(defeating the purpose of moving to kotlin imo)?
Yes, that’s exactly what native libraries require. You have to have a native library built and available for every platform you’re planning on running the code on. For example, for WPILib we build OpenCV 4.5.2 for every platform we support (e.g. Windows, Mac, Linux, RoboRIO, Pi, aarch64).
Re: the UnsatisfiedLinkError, what it’s looking for is a shared library named opencv_java455.so
(on Linux). If it’s not installed system-wide, you’ll need to have its directory location on both java.library.path
and on LD_LIBRARY_PATH
. It also needs to find any dependent libraries, the ldd
command can help figure this out (e.g. ldd opencv_java455.so
).
ok, then I have two questions
-
How did 401 link with just the jar?
-
I ran
sudo make install
for opencv but it still isn’t finding it
Actually, would the aarch64 target you compile for work on a jetson nano?
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.