I'm playing with OpenCV in Java (actually in Scala). I'm using org.bytedeco wrappers (opencpp and javacv), but the documentation is not great.
The question is that depending on the examples, two different APIs are used: org.bytedeco.opencv.opencv_core or org.opencv.core
org.bytedeco.opencv.opencv_core is working fine, but org.opencv.core throws java.lang.UnsatisfiedLinkError:
An exception or error caused a run to abort: no opencv_java410 in java.library.path
java.lang.UnsatisfiedLinkError: no opencv_java410 in java.library.path
I'm completely lost:
Thanks in advance.
Library used: "org.bytedeco" % "javacv-platform" % "1.5.1" that import lib for all platforms.
I'm completely lost:
The org.bytedeco.opencv.opencv_core
and org.opencv.core
libraries are Java bridge libraries that allow the OpenCV native library to be called.
The Java libraries are generated from the C/C++ header files for the OpenCV library. For example, the bytedeco.org site that their version using the JavaCPP tool.
- Why two different apis?
Because two groups decided to do this! Clearly, it isn't a lot of work to generate the Java code.
Why did two groups decide to do the same thing? Pass.
Which one is the one to use?
Questions asking for recommendations are off-topic for StackOverflow, so I won't give one.
A pragmatic answer is to use the one that works for you, but you could also try and figure out what the other one doesn't work.
You should maybe consider the version of the OpenCV API that you want to use, and whether the bridge libraries for that version is available from the respective suppliers.
Why
org.opencv.core
throws exception whenorg.bytedeco.opencv.opencv_core
is working?
Both versions of the library need to link to the OpenCV native library. This is linking is not working for org.opencv.core
on your execution platform. There are a couple of possible reasons for this:
One of the opencv
libraries has an embedded copy of the library and the other doesn't. (Look what is inside the respective JAR files, and compare them to what this Q&A says about how to embed native libraries: How to bundle a native library and a JNI library inside a JAR?)
Alternatively, neither of the JAR files embeds the native library, but your execution has an appropriate version of the library installed already. The version that fails is looking for a library with the name "opencv_java410".