当前位置:  开发笔记 > 编程语言 > 正文

MacOS X安装OpenCV3.2说明介绍

这篇文章讲述MacOSX安装OpenCV3.2说明介绍
windows平台和linux平台安装参见 官方文档:http://docs.opencv.org/3.2.0/da/df6/tutorial_py_table_of_contents_setup.html

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

https://www.learnopencv.com/install-opencv-3-on-yosemite-osx-10-10-x/

核心指令就两句,超简单。

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-configbrew link cmake
brew install opencv3 --without-openexr

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

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

cd /Users/yuetiezhu/anaconda2/envs/tensorflow1.0/lib/python2.7/site-packagesln -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.0python
import cv2

以上就是MacOS X安装OpenCV3.2说明介绍的详细内容,更多请关注 第一PHP社区 其它相关文章!

推荐阅读
家具销售_903
这个屌丝很懒,什么也没留下!
DevBox开发工具箱 | 专业的在线开发工具网站    京公网安备 11010802040832号  |  京ICP备19059560号-6
Copyright © 1998 - 2020 DevBox.CN. All Rights Reserved devBox.cn 开发工具箱 版权所有