ysku's blog

ウェブ・無線通信・組み込みとか

macにpythonのopenCVを入れてみた

画像解析関係を勉強したいなーと思い、pythonopenCVを入れてみました
自分用の簡単なメモになります

まず、homebrewからインストールします
homebrewはパッケージ管理ソフトで、MacPortsに比べ不具合が少ないこともあり有名です

$ /usr/bin/ruby -e "$(/usr/bin/curl -fsSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)"

homebrewのディレクトリを環境変数に追加します

$ vi ~/.bash_profile
export PATH=/usr/local/bin:$PATH

の一行を書き加えます

次にpythonをインストールします

$ brew install python

インストールが終わったら同様にパスを追加します

export PATH=/usr/local/Celler:$PATH

以下のコマンドでリポジトリを追加します

$ brew tap science

いよいよ、openCVを入れます

$ brew install opencv

また.bash_profileに追加します

export PATH=/usr/local/Cellar/opencv/X.X.X/lib/pythonX.X/site-packages:PATH

最後に.bash_profileを反映させます

$ source ~/.bash_profile

以上で、pythonopenCVの使用が可能になります

これでどんどん遊びます