opencv / opencv

Open Source Computer Vision Library
https://opencv.org
Apache License 2.0
76.49k stars 55.64k forks source link

Unable to install OpenCV Java on Mac #25562

Closed vivekburman closed 1 month ago

vivekburman commented 1 month ago

OpenCV - 4.9.x (Latest) MacOS - Ventura 13.6.4 ant: 1.10.14

I'm trying to install opencv with Java bindings on MacOS Intel. I'm following the steps from: https://opencv-java-tutorials.readthedocs.io/en/latest/01-installing-opencv-for-java.html#install-opencv-3-x-under-macos

As per the docs, changing this option to ON -DBUILD_opencv_java=OFF in -DBUILD_opencv_java=ON. Should do the job, but when I run "brew install --build-from-source opencv --verbose" in verbose mode it still takes it as OFF. Below is the screenshot

Screenshot 2024-05-07 at 6 17 11 PM 1

Here the screenshot of opencv file:

image

Kumataro commented 1 month ago

Hello, I'm not macOS user so this is only advice. I'm sorry.

Install steps in this site are here. I read you had done step 2 and step 3.

  1. brew install ant
  2. brew edit opencv and update -DBUILD_opencv_java=ON from OFF
  3. brew install --build-from-source opencv

Maybe it is ok, but please could you confirm your system has installed ant ?

If it is OK, could you get CMake output ?

-- General configuration for OpenCV 4.9.0-dev =====================================
--   Version control:               4.9.0-455-XXXXXXXX
-- 
:
:
--
--   Java:                          
--     ant:                         /usr/local/bin/ant (ver 1.10.12)
--     Java:                        NO
--     JNI:                         /usr/local/include /usr/local/include /usr/local/include
--     Java wrappers:               YES (ANT)
--     Java tests:                  YES
--

OpenCV 4.x document seems to be slightly old...

vivekburman commented 1 month ago

Yes, I've installed ant using 'brew install ant' its version: 1.10.14

vivekburman commented 1 month ago

How do I get the CMake output

Kumataro commented 1 month ago

As first I said I have no macOS. So if it is incorrect, I'm sorry.

  1. You can get CMake output in terminal which you run brew install --build-from-source opencv.
  2. You can get CMake output as version_string.tmp in your work folder,
  3. If build is succeeded completly, you can get CMake output with runnng ,/bin/opencv_version -v comand.
vivekburman commented 1 month ago

Here is the log file attached output.txt

Kumataro commented 1 month ago

Thank you for getting log. It seems that -DBUILD_opencv_java is not updated from OFF to ON.

This log has 4 "cmake -S" lines.

With only this result, it seems opencv.rb is not updated. Please could you confirm that is opencv.rb updated ? (Simplest way is run brew edit opencv again.)


And I confirm OpenCV modules section.

Java module is "Disabled", not "Disabled by dependency". It means the reason of disabled Java module is NOT related with dependency (ant).

--   OpenCV modules:
--     To be built:                 alphamat aruco bgsegm bioinspired calib3d ccalib core d
--     Disabled:                    hdf java world
--     Disabled by dependency:      -
--     Unavailable:                 cannops cudaarithm cudabgsegm cudacodec cudafeatures2d 
--     Applications:                apps
--     Documentation:               NO
--     Non-free algorithms:         YES
vivekburman commented 1 month ago

Hi, I was able to successfully get the build following this article: https://stackoverflow.com/questions/76097556/homebrew-on-mac-not-using-the-edited-opencv-rb-file-via-brew-edit-opencv-during.

Getting opencv-490.jar file successfully.

But the build is showing up on Java 21 although Java is set to 11 on my Mac, attaching the logs here. I tried setting the Java Home before running the process but no luck. output (4).txt

image image

the error is: class file has wrong version 65.0, should be 55.0 for file Imgcodecs.class

Note: I need it to be on Java 11

Kumataro commented 1 month ago

OK, however this seems that question about your setting/environment, not OpenCV issue. Please could you close this issue and ask at Q&A forum ( https://forum.opencv.org/ ) ?