3

I have read through the info docs for bytedeco's opencv gitbub repo and searched extensively on the internet but could not find a solution that works.

I am trying to create an openCV javaFX application with gradle.

I am using this dependency in my gradle.build file: implementation group: 'org.bytedeco', name: 'javacv-platform', version: '1.5.7'

When I run System.loadLibrary(Core.NATIVE_LIBRARY_NAME);, Core.NATIVE_LIBRARY_NAME returns the correct opencv version (opencv_java455).

However, System.loadLibrary("opencv_java455") fails with this error: java.lang.UnsatisfiedLinkError: no opencv_java455 in java.library.path:

What would be the correct way to go about resolving this?

From my digging online, I think that I might be missing a .dylib file. However, I have no idea how to locate this file or how to point to it correctly. I do not see an opencv_java455.dylib file in the external libraries.

Thanks in advance for your help

Here is some more potentially useful information:

Operating system:

MacOS Monterey

M1 chip Macbook pro

Using intelliJ

  • Regarding the opencv library: Is the native library on the `java.library.path`? Is the native library compiled for the M1 architecture? Is the native library compatible with your OS version? If the answer to any of these questions are no, then your setup cannot possibly work. – jewelsea Feb 16 '22 at 04:13
  • Ensure you are using JDK and JavaFX versions 17.0.2+, anything less has issues (crashes) running the native portion of JavaFX on the M1 architecture. – jewelsea Feb 16 '22 at 04:15

1 Answers1

1

There is a special method to call:

Loader.load(opencv_java.class);

Make sure javacpp is in the dependencies and this call will push all needed libraries into the javacpp cache. The manual call of loading any libraries is not needed then. At least this works for all platforms supported, make sure the correct platform libraries are in the classpath (javacpp-platform).

Thomas
  • 1,622
  • 17
  • 24