the glue

やってみたことで忘れそうなこと、役立ちそうなことなどをまとめています。たまに何気ない日常の話もします。

MacにHomebrewでOpenCVを入れる

以前使っていたときはVisual Studioでごにょごにょしてがんばって入れていたのだけど、
OpenCVを使うためだけにVM上にVisual Studioセットアップするのもなんだかなってことで、
HomebrewでOpenCVをインストールしてから使うまでをメモ

入るだろう

% brew install opencv
Error: No available formula for opencv

甘かった

探す

% brew search opencv
homebrew/science/opencv

あった

tap

% brew tap homebrew/science
Cloning into '/usr/local/Library/Taps/homebrew/homebrew-science'...
remote: Reusing existing pack: 5391, done.
remote: Counting objects: 94, done.
remote: Compressing objects: 100% (94/94), done.
remote: Total 5485 (delta 25), reused 0 (delta 0)
Receiving objects: 100% (5485/5485), 1.43 MiB | 573.00 KiB/s, done.
Resolving deltas: 100% (2804/2804), done.
Checking connectivity... done.
Tapped 329 formulae

インストール

% brew install opencv
==> Installing dependencies for opencv: cmake, jpeg, libpng, libtiff, pkg-config
==> Installing opencv dependency: cmake
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/cmake-3.0.0.mavericks.bottle.tar.gz
######################################################################## 100.0%
==> Pouring cmake-3.0.0.mavericks.bottle.tar.gz
?  /usr/local/Cellar/cmake/3.0.0: 1622 files, 25M
==> Installing opencv dependency: jpeg
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/jpeg-8d.mavericks.bottle.2.tar.gz
######################################################################## 100.0%
==> Pouring jpeg-8d.mavericks.bottle.2.tar.gz
?  /usr/local/Cellar/jpeg/8d: 18 files, 780K
==> Installing opencv dependency: libpng
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/libpng-1.6.12.mavericks.bottle.tar.gz
######################################################################## 100.0%
==> Pouring libpng-1.6.12.mavericks.bottle.tar.gz
?  /usr/local/Cellar/libpng/1.6.12: 17 files, 1.2M
==> Installing opencv dependency: libtiff
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/libtiff-4.0.3.mavericks.bottle.tar.gz
######################################################################## 100.0%
==> Pouring libtiff-4.0.3.mavericks.bottle.tar.gz
?  /usr/local/Cellar/libtiff/4.0.3: 254 files, 3.8M
==> Installing opencv dependency: pkg-config
==> Downloading https://downloads.sf.net/project/machomebrew/Bottles/pkg-config-0.28.mavericks.bottle.2.tar.gz
######################################################################## 100.0%
==> Pouring pkg-config-0.28.mavericks.bottle.2.tar.gz
?  /usr/local/Cellar/pkg-config/0.28: 10 files, 604K
==> Installing opencv
==> Downloading https://github.com/Itseez/opencv/archive/2.4.9.tar.gz
######################################################################## 100.0%
==> cmake .. -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/opencv/2.4.9 -DCMAKE_BUILD_TYPE=None -DCMAKE_FIND_FRAMEWORK=LAST -DCMAKE_VERBOSE_MAKEFILE=ON -Wno-dev -DCMAKE_OSX_DEPLOYMENT_TARGET= -DBUILD_ZLIB=OFF -DBUILD_TIFF=OFF -DBUILD_PNG=OFF -
==> make
==> make install
==> Caveats
If you need Python to find the installed site-packages:
  mkdir -p ~/Library/Python/2.7/lib/python/site-packages
  echo '/usr/local/lib/python2.7/site-packages' > ~/Library/Python/2.7/lib/python/site-packages/homebrew.pth
==> Summary
?  /usr/local/Cellar/opencv/2.4.9: 219 files, 38M, built in 5.5 minutes

とりあえずインストールできたみたい

追記予定