2011年9月19日月曜日

MacへのOpenCVインストール

MacへOpenCVをインストール
Pythonから呼び出すため、Python 2.7とともにインストール

今回は、ソースコードからではなく、MacPortsを利用してインストール
(依存モジュールが多いため)

1.MacPortsのインストール
http://www.macports.org/からインストーラをダウンロードして、簡単にインストールできる
2.MacPortsでOpenCVをインストール
ターミナルを起動し、次のコマンドを実行すれば、インストールが開始する
# sudo port install opencv +python27

・MacPortsでインストール中にPerlがエラーを起こした
Error: Target org.macports.activate returned: Image error: /opt/local/bin/a2p is being used by the active perl5.8 port.  Please deactivate this port first, or use 'port -f activate perl5' to force the activation.
エラー内にあるport -f activate perl5を実行しても、うまくいかなかった
対策としては、activeなperl5.8をアンインストールして、最新のPerlだけにすればよい

手順は次の通り
1.インストールされているPerlを表示
# sudo port installed | grep perl
 perl5 @5.8.9_0
 perl5 @5.12.3_0+perl5_12
 perl5.8 @5.8.9_3 (active)
 perl5.12 @5.12.3_1 (active)
2.インストールされているPerlの中から、古いバージョンのものをアンインストール
# sudo port uninstall perl5 @5.8.9_0
# sudo port uninstall perl5.8

これで、OpenCVのインストールを再会すればインストールできる
(インストールが完了するまでに、2時間ほどかかった・・・)