Current is 2022. The brew tool and pip tool could support OpenCV-4.6 very well.
Use brew tool:
1, install java if needed
brew install openjdk
If have error message ‘No Java Runtime present,requesting to install’, we need to complete the environment path. Use ‘temurin’ to casting from the env-path.
brew install temurin
2, install ant before install the OpenCV library
brew install ant
3, install OpenCV (version 4.6.0)
By default, install opencv by brew won’t support Java, need to update the install script before build.
brew edit opencv
Find a line:
Then install the OpenCV
brew install --build-from-source opencv
4, verify the library. The jar and dylib files will be located at /opt/homebrew/Cellar/opencv/4.6.0_1/share/java folder
brew info opencv
tabtu@ttAir ~ % brew info opencv ==> opencv: stable 4.6.0 (bottled) Open source computer vision library