mac安装opencv

2022-06-11  本文已影响0人  勤的空间

我的系统是macOS Catalina,安装opencv步骤如下,参考文档https://blog.csdn.net/lifetragedy/article/details/123459339

  1. vi ~/.zshrc,加入:
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles
export 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-bottleshttps://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles

  1. 执行source ~/.zshrc
  2. 执行brew update
  3. 执行brew edit opencv,把-DBUILD_opencv_java=OFF 修改为-DBUILD_opencv_java=ON
  4. 安装JAVAbrew install openjdk,会安装java18
  5. 在~/.zshrc加入java18的JAVA_HOME环境变量export JAVA_HOME=/usr/local/Cellar/openjdk/18
  6. 执行brew install ant
  7. 执行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
  8. 查看安装目录:/usr/local/Cellar/opencv/4.5.5,安装成功
  9. /usr/local/share/java/opencv4/libopencv_java454.dylib文件拷贝到jdk的lib目录下
上一篇下一篇

猜你喜欢

热点阅读