Python-OpenCV 安装

OpenCV 安装流程。

安装依赖包

1
2
3
brew install cmake pkg-config
brew install jpeg libpng libtiff openexr
brew install eigen tbb

安装 OpenCV

1
2
brew tap homebrew/science
brew install opencv

在 Tensorflow 中使用:

1
2
cd /Users/YI/tensorflow/lib/python2.7/site-packages
ln -s /usr/local/lib/python2.7/site-packages/cv2.so cv2.so

设置路径

Python-OpenCV

1
2
mkdir -p /Users/YI/Library/Python/2.7/lib/python/site-packages
echo 'import site; site.addsitedir("/usr/local/lib/python2.7/site-packages")' >> /Users/YI/Library/Python/2.7/lib/python/site-packages/homebrew.pth

建立软连接

1
2
sudo ln -s /usr/local/Cellar/opencv/2.4.13.2/lib/python2.7/site-packages/cv.py /Library/Python/2.7/site-packages/cv.py
sudo ln -s /usr/local/Cellar/opencv/2.4.13.2/lib/python2.7/site-packages/cv2.so /Library/Python/2.7/site-packages/cv2.so

Raspberry

1
2
3
4
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install libopencv-dev
sudo apt-get install python-opencv

XCODE

1
2
3
Header Search Paths -> /usr/local/include/
Library Search Paths -> /usr/local/lib
并把 lib 下的库复制到项目中
YI wechat
欢迎您扫一扫上面的微信公众号,订阅我的博客!