Java – Which Java API is used with JavaCV? org.bytedeco.opencv.opencv_core or org.opencv.core?

Which Java API is used with JavaCV? org.bytedeco.opencv.opencv_core or org.opencv.core?… here is a solution to the problem.

Which Java API is used with JavaCV? org.bytedeco.opencv.opencv_core or org.opencv.core?

I use OpenCV in Java (actually in Scala).
I’m using the org.bytedeco wrapper (opencpp and javacv), but the documentation isn’t great.

The problem is that, depending on the example, two different APIs are used: org.bytedeco.opencv.opencv_core or org.opencv.core

org.bytedeco.opencv.opencv_core works 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 was completely lost :

  1. Why use two different APIs?
  2. Which one to use?
  3. Why does org.opencv.core throw an exception when org.bytedeco.opencv.opencv_core is working properly?

Thanks in advance.

Libraries used: “org.bytedeco” % “javacv-platform” % “1.5.1” import libraries for all platforms.

Solution

I’m completely lost:

org.bytedeco.opencv.opencv_core and org.opencv.core libraries are Java bridge libraries that allow OpenCV native libraries to be summoned.
Java libraries are generated from the C/C++ header files of the OpenCV library. For example, bytedeco.org their version is used JavaCPP’s website tool.

  1. Why two different apis?

Because the two groups decided to do it! Obviously, generating Java code is not a lot of work.

Why did the two groups decide to do the same thing? Pass.

Which one is the one to use?

The question of asking for a recommendation has nothing to do with StackOverflow, so I won’t give it.

The practical answer is to use the one that works for you, but you can also try to find out which one doesn’t.

You might want to consider which version of the OpenCV API to use, and whether the bridge library for that version is available from the appropriate vendor.

Why org.opencv.core throws exception when org.bytedeco.opencv.opencv_core is working?

Both versions of the library need to link to the OpenCV native library. This link does not apply to org.opencv.core on your execution platform. There are several possible reasons for this:

  1. One of the OpenCV libraries has an embedded copy of the library, while the other does not. (Look at the contents of the individual JAR files and compare them to the content in this Q&A on how to embed the native library: How to bundle a native library and a JNI library inside a JAR?)

  2. Alternatively, neither JAR file has a native library embedded, but your execution already has an appropriate version of the library installed. The failed version is looking for a library named “opencv_java410”.

Related Problems and Solutions