LoginSignup
44
44

More than 5 years have passed since last update.

Homebrewを使ってMacにOpenCVを導入するまで

Posted at

参考書籍を読みつつOpenCVをインストールするまでのメモ。
今回はHomebrewからパッケージをインストールするだけの簡単なお仕事…でもなかったので書籍になかったつまづきポイントをまとめてます。

環境

MacBook Air Mid 2012
OS X Mountain Lion 10.8.4
Core i5 1.8GHz
8GB RAM

Homebrewのセットアップ

とりあえず

brew doctor
brew update

を実行したところupdateでエラー。

error: The following untracked working tree files would be overwritten by merge:
    Library/Formula/haxe.rb
    Library/Formula/log4shib.rb
    Library/Formula/opensaml.rb
    Library/Formula/osm2pgsql.rb
    Library/Formula/re2.rb
    Library/Formula/rebar.rb
    Library/Formula/xml-security-c.rb
    Library/Formula/xml-tooling-c.rb
Please move or remove them before you can merge.

SOFによると、brewのローカルブランチが古いからresetしろとのこと。

~ root# cd /usr/local
local root# git fetch origin
remote: Counting objects: 121, done.
remote: Compressing objects: 100% (62/62), done.
remote: Total 111 (delta 51), reused 100 (delta 40)
Receiving objects: 100% (111/111), 26.87 KiB, done.
Resolving deltas: 100% (51/51), completed with 7 local objects.
From https://github.com/mxcl/homebrew
   8a77613..6305d2d  gh-pages   -> origin/gh-pages
   9e8ffa9..3e7f9ae  go         -> origin/go
   de55321..fbc33db  master     -> origin/master
local root# git reset --hard origin/master
HEAD is now at fbc33db libcppa: 0.7.1 - Actor Model implementation for C++11

問題なくbrew updateは通った。

おまちかねのOpenCVインストール

さて、OpenCV用のパッケージ入れます。

$ brew install opencv                                                                                                                                                     Warning: It appears you have MacPorts or Fink installed.
Software installed with other package managers causes known problems for
Homebrew. If a formula fails to build, uninstall MacPorts/Fink and try again.
Error: No available formula for opencv

Warningの件はMacPorts入れてたのが原因。
現在MacPortsで管理してるパッケージはないので削除することに。

$ sudo port -f uninstall installed
$ sudo rm -rf /opt/local

で、OpenCVライブラリが見つからないエラーはここで解決。
デフォルトで入ってないのでscience入れてねというのは罠ですね。

$ brew tap homebrew/science

このtapというコマンドの説明はこちらで解説されてる。
ようやくインストール。

$ sudo brew install opencv

おわり。

参考資料

OS XとiOSのためのOpenCV環境構築ガイド

44
44
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
44
44