1.安装homebrewpython
网上方法不少,自行搜索git
2.安装cmakegithub
sudo brew install cmake
3.下载opencv源代码bash
wget https://github.com/Itseez/opencv/archive/2.4.13.zip
4.解压安装python2.7
unzip 2.4.13.zip cd opencv-2.4.13/ mkdir build cd build/ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON -D BUILD_EXAMPLES=ON .. make sudo make install
5.将cv2.so文件连接到python的site-packages目录测试
sudo ln -s /usr/local/lib/python2.7/site-packages/cv2.so /Library/Python/2.7/site-packages/
6.python里测试ui
>>> import cv2 >>> print cv2.__version__ 2.4.13
另:homebrew 能够直接安装opencv,没有测试,这里仅供参考:blog
brew update brew tap homebrew/homebrew-science brew install opencv