Home >Backend Development >Python Tutorial >Instructions for installing OpenCV3.2 on MacOS X

Instructions for installing OpenCV3.2 on MacOS X

高洛峰
高洛峰Original
2017-03-16 09:38:561856browse

windows platform and linuxplatformInstallationSee the official documentation: http://docs.opencv.org/3.2.0/da/df6/tutorial_py_table_of_contents_setup.html

The official platform cannot be found when installed under mac. Reference:

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

Core instructions Just two sentences, super simple.

brew tap homebrew/science
brew install opencv3


#But we also encountered a bunch of problems. The recording process is as follows:

1.

brew install opencv3


Error report:

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


2. I thought there was no To install openexr, I checked http://www.openexr.com/ and I think it’s okay not to install it. There happens to be the --without-openexr option, so:

brew install opencv3 --without-openexr


Error report:

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. Then follow the prompts:

brew link pkg-config
Error report:


Error: Could not symlink share/aclocal/pkg.m4/usr/local/share/aclocal is not writable.
4. Oh, no permissions. Then:


sudo brew link pkg-config
Error:


Error: Running Homebrew as root is extremely dangerous and no longer supported.
5. It turns out that it is not allowed, so I have to change the folder permissions


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
is successful. It is estimated that the error reported in the first step is also a problem of not having permission to create a software connection.


6. Link to the

python environment. I am linking to the tensorflow1.0 environment built by anaconda

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 There is no cv.py, only cv2.so, but it can be used


7. Test it

source activate tensorflow1.0python
import cv2



The above is the detailed content of Instructions for installing OpenCV3.2 on MacOS X. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn