zoukankan      html  css  js  c++  java
  • MacOS X 安装OpenCV3.2

    windows平台和linux平台安装参见 官方文档:http://docs.opencv.org/3.2.0/da/df6/tutorial_py_table_of_contents_setup.html

    mac下安装在官方平台没找到。参考:

     
    核心指令就两句,超简单。
    brew tap homebrew/science
    brew install opencv3

    但是也遇到了一堆问题。记录过程如下:

    1. 
    brew install opencv3

    报错:

    Error: You must `brew link openexr` before homebrew/science/opencv3 can be installed

    2. 以为没有装openexr, 查了一下http://www.openexr.com/ 觉得不装也可以,刚好有 --without-openexr这个选项,因此:

    brew install opencv3 --without-openexr

    报错:

    Error: The `brew link` step did not complete successfully
    The formula built, but is not symlinked into /usr/local
    Could not symlink share/aclocal/cmake.m4
    /usr/local/share/aclocal is not writable.
    
    You can try again using:
      brew link cmake
    
    ………………

    3. 那就按照提示吧:

    brew link pkg-config

    报错:

    Error: Could not symlink share/aclocal/pkg.m4
    /usr/local/share/aclocal is not writable.

    4. 哦,没权限。那么:

    sudo brew link pkg-config

    报错:

    Error: Running Homebrew as root is extremely dangerous and no longer supported.

    5. 原来不允许,那么只好改文件夹权限了

    whoami
    # 下面两个命令中的‘whoami’用刚才命令的输出代替
    sudo chown -R 'whoami':admin /usr/local/share         
    sudo chown -R 'whoami':admin /usr/local/local/bin
    brew link pkg-config
    brew link cmake
    brew install opencv3 --without-openexr

    成功,估计一开始的第一步报的错误,也是没有没有权限建立软件接的问题。

    6. 链接到python环境,我这是链接到anaconda建的tensorflow1.0环境下

    cd /Users/yuetiezhu/anaconda2/envs/tensorflow1.0/lib/python2.7/site-packages
    ln -s /usr/local/Cellar/opencv3/3.2.0/lib/python2.7/site-packages/cv2.so cv2.so

    /usr/local/Cellar/opencv3/3.2.0/lib/python2.7/site-packages 没有cv.py 只有cv2.so,但是可以用啦

    7. 测试一下

    source activate tensorflow1.0
    python
    import cv2

    OK了。

  • 相关阅读:
    三十五、常用控件
    三十九.导入工程出错
    三十七、创建无图标的应用
    三十二、汉字排序
    三十八、分辨率适配方法
    四十一、打开各种文件的intent
    ExamTime
    MusicPXY3.1
    单目运算符的最新认识
    寄快递费用
  • 原文地址:https://www.cnblogs.com/yuetz/p/6554440.html
Copyright © 2011-2022 走看看