6

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:

  1. Why two different apis?
  2. Which one is the one to use?
  3. Why org.opencv.core throws exception when org.bytedeco.opencv.opencv_core is working?

Thanks in advance.

Library used: "org.bytedeco" % "javacv-platform" % "1.5.1" that import lib for all platforms.

1
  • 1
    We would need to patch the loader from the org.opencv package to use JavaCPP's loader. That's not currently being done, so we need to do it manually as indicated in the README.md file here: github.com/bytedeco/javacpp-presets/tree/master/… Contributions to enhance this are welcome though! Commented Oct 21, 2019 at 2:29

1 Answer 1

3

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.

  1. 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 when org.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:

  1. 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?)

  2. 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".

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

2 Comments

Thanks for your response. So basically, two different approaches, one is loading the embedded binary libraries automatically and the other one delegate this to the user so needs to have OpenCV installed in your environment.
Yes ... though I don't know this the actual issue here.

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.