opencv をYosemiteにインストール

参考にしたサイト:

http://www.mobileway.net/2015/02/14/install-opencv-for-python-on-mac-os-x/

 

(1)
$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

(2)
$ brew update

(3)
$ brew tap homebrew/science

(4)
$ brew install opencv

出力結果の最後は以下の通り:

Possible conflicting files are:
/usr/local/bin/f2py
==> Caveats
If you use system python (that comes - depending on the OS X version -
with older versions of numpy, scipy and matplotlib), you may need to
ensure that the brewed packages come earlier in Python's sys.path with:
mkdir -p /Users/[my_name]/.local/lib/python2.7/site-packages
echo 'import sys; sys.path.insert(1, "/usr/local/lib/python2.7/site-packages")' >> /Users/[my_name]/.local/lib/python2.7/site-packages/homebrew.pth
==> Summary
? /usr/local/Cellar/numpy/1.11.2: 433 files, 9.1M
==> Installing homebrew/science/opencv
==> Downloading https://homebrew.bintray.com/bottles-science/opencv-2.4.13_3.yosemite.bottle.tar.gz
######################################################################## 100.0%
==> Pouring opencv-2.4.13_3.yosemite.bottle.tar.gz
? /usr/local/Cellar/opencv/2.4.13_3: 276 files, 35.7M


と出てきた。

(5)
上記の情報を参考に、.bash_profile の末尾に下記を書き込む:

$ cd
$ vi .bash_profile

#================================
# Added by [my_name] when installing opencv
export PYTHONPATH=$PYTHONPATH:/usr/local/Cellar/opencv/2.4.13_3/lib/python2.7/site-packages
#================================

(6)
$ source .bash_profile

(7)確認
$ python -c ‘import cv2’