Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opencv not found after installation via update site #11

Open
amichaut opened this issue Feb 28, 2023 · 6 comments
Open

opencv not found after installation via update site #11

amichaut opened this issue Feb 28, 2023 · 6 comments

Comments

@amichaut
Copy link

Hi,
I have followed the installation procedure via the Fiji updater.
I can see that IJ-opencv and multi-template-matching are installed (as they appear in the plugins dropdown menu).

However, when I run the Template Matching Image function, I have an error saying that the OpenCV dependencies are missing and the following error is raised:
java.lang.NoClassDefFoundError: java.lang.NoClassDefFoundError: Could not initialize class org.bytedeco.javacpp.opencv_core

System:
macOS 12.6.3
Fiji 2.9.0/1.53t

@LauLauThom
Copy link
Collaborator

Hi there,
thanks for reporting the issue,

The problematic import statement is the following one :

from org.bytedeco.javacpp.opencv_core import Mat, Scalar, Point, minMaxLoc, subtract # UNUSED normalize, NORM_MINMAX, CV_8UC1, CV_32FC1

To reproduce the issue, I believe activating IJ-OpenCV and running this line in the script editor, selecting python as language should trigger a similar error.

I dont have a solution, but I think it might be due to the operating system.
The import statement above, loads the opencv functions from platform-specific jars.
All of them are shipped with the update site, and by some magic, the correct package is imported.
It seems it's not the case for your OS.

Can you first check that you have all these jars in the subfolder jars of your Fiji installation ?
image

If yes, maybe try moving all these packages out of the jars directory, except for the macosx one.

@amichaut
Copy link
Author

amichaut commented Mar 3, 2023

Hi,
Thanks for the reply!
Running the import line in a script editor reproduces the error indeed.
I moved out the linux and windows jars but running the import line in a script editor still raises the following error:
Caused by: java.lang.UnsatisfiedLinkError: /Users/amichaut/.javacpp/cache/opencv-3.4.2-1.4.2-macosx-x86_64.jar/org/bytedeco/javacpp/macosx-x86_64/libjniopencv_core.dylib: dlopen(/Users/amichaut/.javacpp/cache/opencv-3.4.2-1.4.2-macosx-x86_64.jar/org/bytedeco/javacpp/macosx-x86_64/libjniopencv_core.dylib, 0x0001): Library not loaded: '@rpath/libopencv_imgproc.3.4.dylib' Referenced from: '/Users/amichaut/.javacpp/cache/opencv-3.4.2-1.4.2-macosx-x86_64.jar/org/bytedeco/javacpp/macosx-x86_64/libjniopencv_core.dylib' Reason: tried: '/Applications/Fiji.app/lib/macosx/libopencv_imgproc.3.4.dylib' (no such file), '/Applications/Fiji.app/mm/macosx/libopencv_imgproc.3.4.dylib' (no such file), '/Users/amichaut/.javacpp/cache/opencv-3.4.2-1.4.2-macosx-x86_64.jar/org/bytedeco/javacpp/macosx-x86_64/./libopencv_imgproc.3.4.dylib' (no such file), '/Users/travis/build/bytedeco/javacpp-presets/opencv/cppbuild/macosx-x86_64/lib/libopencv_imgproc.3.4.dylib' (no such file), '/Users/amichaut/.javacpp/cache/opencv-3.4.2-1.4.2-macosx-x86_64.jar/org/bytedeco/javacpp/maco

@LauLauThom
Copy link
Collaborator

Interesting, I had never noticed some files were being cached in the user directory ^^ !
It seems in your case it cant find the file related to opencv_imgproc

This is what I have in my user directory .javacpp/cache...
image

Do you have something like that in your directory ? if yes do you have a file with imgproc in the name ?

@amichaut
Copy link
Author

amichaut commented Mar 3, 2023

Yes I have. but it is a .dylib file (and actually it's a symbolic link pointing to another directory in the cache). Here's the content of the directory

-rw-r--r--  1 amichaut  staff   3,9M 16 jul  2018 libjniopencv_core.dylib
lrwxr-xr-x  1 amichaut  staff   115B 28 fév 19:14 libopencv_core.4.0.dylib@ -> /Users/amichaut/.javacpp/cache/opencv-macosx-x86_64.jar/org/bytedeco/javacpp/macosx-x86_64/libopencv_core.4.0.dylib
lrwxr-xr-x  1 amichaut  staff   118B 28 fév 19:14 libopencv_imgproc.4.0.dylib@ -> /Users/amichaut/.javacpp/cache/opencv-macosx-x86_64.jar/org/bytedeco/javacpp/macosx-x86_64/libopencv_imgproc.4.0.dylib

@LauLauThom
Copy link
Collaborator

hmm not sure what is going wrong there, maybe some permission issue on the directory ?
Is there a way to run Fiji in admin ? Maybe delete the content of this cache directory.

Eventually you can try the next version of these dependencies, maybe it was fixed by then.
Try version 3.4.3-1.4.3 for instance.

It's a bit tedious you have to download the packages manually from the link below, clicking the market artefact then download button on the right(see screencapture).
And move the previous jar out of the Fiji.app/jars directory.
image

So opencv
https://oss.sonatype.org/#nexus-search;gav~org.bytedeco.javacpp-presets~opencv~~~~kw,versionexpand

Same for JavaCV (take the matching version, so here it would be 1.4.3)
https://oss.sonatype.org/#nexus-search;quick~javacv
image

and javacpp
https://oss.sonatype.org/#nexus-search;gav~org.bytedeco~javacpp~~~
image

Otherwise it can be worse searching through (the numerous) issues of javacpp
https://github.com/bytedeco/javacpp/issues?q=is%3Aissue+mac+

@amichaut
Copy link
Author

amichaut commented Mar 3, 2023

ok, thanks a lot for your help. I have just tried removing the cache directory for now but it didn't change anything

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants