インストールに時間がかかるものを、お盆前の暇なうちに入れ直しておく。
OpenCV3 に乗り換え
仕事用のWindowsは、OpenCV2とOpenCV3の混在環境になっていて、
cuda版も合わせて4種類でビルドしたライブラリを使い分けてる。
ちょっとイヤな感じ。
OpenCV3で心底困る事は無いし、機械学習には具合が良いから、
MacBookProの環境は OpenCV3 に乗り換えよう。
まずは、一応OpenCV2も更新しておこう。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
$ $ brew install opencv --with-eigen --with-jasper --with-libtiff --with-qt --with-tbb --with-ffmpeg --with-opencl ==> Reinstalling homebrew/science/opencv with --with-jasper, --with-qt, --with-t ==> Installing dependencies for homebrew/science/opencv: mpfr, gcc, cmake .... ==> Installing homebrew/science/opencv dependency: gcc ==> Downloading http://ftpmirror.gnu.org/gcc/gcc-5.2.0/gcc-5.2.0.tar.bz2 ==> Downloading from http://ftp.jaist.ac.jp/pub/GNU/gcc/gcc-5.2.0/gcc-5.2.0.tar.bz2 ######################################################################## 100.0% ==> Patching patching file gcc/jit/Make-lang.in ==> ../configure --build=x86_64-apple-darwin14.4.0 --prefix=/usr/local/Cellar/gcc/5.2.0 --libdir=/usr/local/Cellar ==> make bootstrap # ここで30分程 ==> make install ==> Caveats GCC has been built with multilib support. Notably, OpenMP may not work: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=60670 If you need OpenMP support you may want to brew reinstall gcc --without-multilib ==> Summary 🍺 /usr/local/Cellar/gcc/5.2.0: 1353 files, 248M, built in 32.5 minutes ==> Installing homebrew/science/opencv dependency: cmake .... ==> Downloading https://github.com/Itseez/opencv/archive/2.4.11.tar.gz Already downloaded: /Library/Caches/Homebrew/opencv-2.4.11.tar.gz ==> Downloading https://gist.githubusercontent.com/tdsmith/484553cd2d0c19a4baa7/raw/b766154fa6c7ac1be3491b0c6b58b3 Already downloaded: /Library/Caches/Homebrew/opencv--patch-cfe31c32d5a4ef0e89df684e210360602fb2d295b19f9ca4791731a9e274d776.diff ==> Patching patching file modules/python/CMakeLists.txt ==> cmake .. -DCMAKE_C_FLAGS_RELEASE= -DCMAKE_CXX_FLAGS_RELEASE= -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/opencv/2 ==> make ==> make install Warning: homebrew/science/opencv dependency gcc was built with a different C++ standard library (libstdc++ from clang). This may cause problems at runtime. 🍺 /usr/local/Cellar/opencv/2.4.11_1: 222 files, 35M, built in 4.2 minutes |
gccも再インストールしたので、
ここまでで45分ほど。
ログを見ると、あれれ。
1 2 3 |
If you need OpenMP support you may want to brew reinstall gcc --without-multilib |
openMPを使えるように、gccを再ビルド
multilibは必要ないけどOpenMPは欲しいのでヤリ直し。
ログは省略。
さて。OpenCV3をのインストール
1 2 3 4 |
$ $ brew info opencv3 $ brew search opencv3 |
あれ?、 OpenCV3 が見付からない。
リポジトリを直接見ると有るんだけどな。
さっき brew update はしたし。。。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
$ $ brew options opencv --32-bit Build 32-bit only --c++11 Build using C++11 mode --with-cuda Build with CUDA support --with-ffmpeg Build with ffmpeg support --with-gstreamer Build with gstreamer support --with-jasper Build with jasper support --with-java Build with Java support --with-libdc1394 Build with libdc1394 support --with-opengl Build with OpenGL support --with-openni Build with openni support --with-qt Build the Qt4 backend to HighGUI --with-quicktime Use QuickTime for Video I/O insted of QTKit --with-tbb Enable parallel code in OpenCV using Intel TBB --without-eigen Build without eigen support --without-numpy Use a numpy you've installed yourself instead of a Homebrew-packaged numpy --without-opencl Disable GPU code in OpenCV using OpenCL --without-openexr Build without openexr support --without-python Build without Python support --without-tests Build without accuracy & performance tests --devel Install development version 3.0.0-rc1 --HEAD Install HEAD version |
どうやら、opencvに取り込まれたみたいだ。
OpenCV3はリリースしたてだし、 3.0.0-rc1 よりは HEAD だよね。
ビルドオプションも、今のに合わせて再ビルド。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
$ $ brew reinstall opencv --with-ffmpeg --with-jasper --with-qt --with-tbb --HEAD ==> Reinstalling homebrew/science/opencv with --with-jasper, --with-qt, --with-tbb, --with-ffmpeg ==> Using Homebrew-provided fortran compiler. This may be changed by setting the FC environment variable. ==> Cloning https://github.com/Itseez/opencv.git Cloning into '/Library/Caches/Homebrew/opencv--git'... remote: Counting objects: 5419, done. remote: Compressing objects: 100% (4761/4761), done. remote: Total 5419 (delta 835), reused 3114 (delta 429), pack-reused 0 Receiving objects: 100% (5419/5419), 69.48 MiB | 539.00 KiB/s, done. Resolving deltas: 100% (835/835), done. Checking connectivity... done. ==> Checking out branch master ==> cmake .. -DCMAKE_C_FLAGS_RELEASE= -DCMAKE_CXX_FLAGS_RELEASE= -DCMAKE_INSTALL_PREFIX=/usr/local/Cellar/opencv/H ==> make ==> make install Warning: homebrew/science/opencv dependency gcc was built with a different C++ standard library (libstdc++ from clang). This may cause problems at runtime. 🍺 /usr/local/Cellar/opencv/HEAD: 246 files, 103M, built in 10.1 minutes |
OpenCVのバージョン確認
インストールは10分ほどで終了。
念のためバージョンを確認しょう。
1 2 3 4 5 6 7 8 9 10 |
$ $ python Python 2.7.10 (default, Jun 2 2015, 00:10:05) [GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin Type "help", "copyright", "credits" or "license" for more information. >>> import cv2 >>> cv2.__version__ '3.0.0-dev' >>> exit(0) |
ちゃんと、 OpenCV3 になってました。
それにしても…
2015年の MacbookPro Retina 15は、2012年版よりもファンがやかましい。
Homebrewのインストールではファンが回りっぱなしで、膝がメチャ熱い。