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

Unable to install OpenCV Java on Mac #25562

Closed
vivekburman opened this issue May 8, 2024 · 8 comments
Closed

Unable to install OpenCV Java on Mac #25562

vivekburman opened this issue May 8, 2024 · 8 comments
Labels
category: build/install question (invalid tracker) ask questions and other "no action" items here: https://forum.opencv.org

Comments

@vivekburman
Copy link

vivekburman commented May 8, 2024

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
Copy link
Contributor

Kumataro commented May 8, 2024

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
Copy link
Author

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

@vivekburman
Copy link
Author

How do I get the CMake output

@Kumataro
Copy link
Contributor

Kumataro commented May 8, 2024

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.

@opencv-alalek opencv-alalek added question (invalid tracker) ask questions and other "no action" items here: https://forum.opencv.org category: build/install labels May 8, 2024
@vivekburman
Copy link
Author

vivekburman commented May 8, 2024

Here is the log file attached
output.txt

@Kumataro
Copy link
Contributor

Kumataro commented May 8, 2024

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.

  • L1111: -DBUILD_opencv_java=OFF
  • L1610: none
  • L5478: -DBUILD_opencv_java=OFF
  • L5987: none

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
Copy link
Author

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
Copy link
Contributor

Kumataro commented May 9, 2024

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/ ) ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: build/install question (invalid tracker) ask questions and other "no action" items here: https://forum.opencv.org
Projects
None yet
Development

No branches or pull requests

3 participants