安装opencv在MacOS上
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了安装opencv在MacOS上相关的知识,希望对你有一定的参考价值。
1. 使用brew安装opencv
brew tap homebrew/science
brew install opencv
ls /Users/mac/Library/Python/2.7/lib/python/site-packages
mkdir -p /Users/mac/Library/Python/2.7/lib/python/site-packages
sudo mkdir -p /Users/mac/Library/Python/2.7/lib/python/site-packages
echo ‘import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")‘ >> /Users/mac/Library/Python/2.7/lib/python/site-packages/homebrew.pth
2. 查找到安装opencv库文件位置:
/usr/local/Cellar/opencv/2.4.13.2/lib/python2.7/site-packages/cv.py
/usr/local/Cellar/opencv/2.4.13.2/lib/python2.7/site-packages/cv2.so
3. 加入环境变量:
export PYTHONPATH=/usr/local/Cellar/opencv/2.4.13.2/lib/python2.7/site-packages/:$PYTHONPATH
4. 如果import cv2是出现ImportError: numpy.core.multiarray failed to import 请更新numpy库。
sudo pip install numpy --upgrade --ignore-installed
以上是关于安装opencv在MacOS上的主要内容,如果未能解决你的问题,请参考以下文章
如何在 MacOS 上使用 OpenCV 链接 C++ 程序 [重复]