zt3ff3n 发表于 2022-6-11 10:43

mac安装opencv

我的系统是macOS Catalina,安装opencv步骤如下,参考文档https://blog.csdn.net/lifetragedy/article/details/123459339:
vi ~/.zshrc,加入:
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottlesexport SSL_CERT_DIR="/usr/local/etc/openssl/certs"export SSL_CERT_FILE="/usr/local/etc/openssl/cert.pem"
brew源可以选择https://mirrors.ustc.edu.cn/homebrew-bottles或https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles
执行source ~/.zshrc执行brew update执行brew edit opencv,把-DBUILD_opencv_java=OFF 修改为-DBUILD_opencv_java=ON安装JAVAbrew install openjdk,会安装java18在~/.zshrc加入java18的JAVA_HOME环境变量export JAVA_HOME=/usr/local/Cellar/openjdk/18执行brew install ant
[*]执行brew install --build-from-source opencv
可能会卡在安装依赖
==> Installing dependencies for opencv: nettle, p11-kit,....,报错Error: No such file or directory @ rb_sysopen
解决方法:把那些依赖复制下来去掉逗号,用brew install 单独安装一次,如:
brew install nettle p11-kit libevent libnghttp2 unbound gnutls lame libass libbluray cjson cmocka mbedtls librist libsoxr libvidstab libogg libvorbis libvpx opencore-amr opus rav1e flac libsndfile libsamplerate rubberband sdl2 snappy speex srt libarchive tesseract theora x264 x265 xvid libsodium zeromq zimg ffmpeg@4 numpy protobuf boost gl2ps glew libaec hdf5 jsoncpp netcdf pugixml pyqt@5 utf8cpp vtk
然后再执行:brew install --build-from-source opencv查看安装目录:/usr/local/Cellar/opencv/4.5.5,安装成功将/usr/local/share/java/opencv4/libopencv_java454.dylib文件拷贝到jdk的lib目录下
页: [1]
查看完整版本: mac安装opencv