OpenCV 2.0 betaインストールしてみた

Open Computer Vision Library@SourceForge.netにて
OpenCV 2.0 beta(※2009/9/12現在はWindows版のみ)が
リリースされたということでインストールしてみました.

また,OpenCV 1.1preからの変更点について
ChangeLogの記述を抜粋しました.

>>> New functionality, features: <<< - General: * The brand-new C++ interface for most of OpenCV functionality (cxcore, cv, highgui) has been introduced. Generally it means that you will need to do less coding to achieve the same results; it brings automatic memory management and many other advantages. See the C++ Reference section in opencv/doc/opencv.pdf and opencv/include/opencv/*.hpp. The previous interface is retained and still supported. * The source directory structure has been reogranized; now all the external headers are placed in the single directory on all platforms. * The primary build system is CMake, http://www.cmake.org (2.6.x is the preferable version). + In Windows package the project files for Visual Studio, makefiles for MSVC, Borland C++ or MinGW are note supplied anymore; please, generate them using CMake. + In MacOSX the users can generate project files for Xcode. + In Linux and any other platform the users can generate project files for cross-platform IDEs, such as Eclipse or Code Blocks, or makefiles for building OpenCV from a command line. * OpenCV repository has been converted to Subversion, hosted at SourceForge: http://opencvlibrary.svn.sourceforge.net/svnroot/opencvlibrary where the very latest snapshot is at http://opencvlibrary.svn.sourceforge.net/svnroot/opencvlibrary/trunk, and the more or less stable version can be found at http://opencvlibrary.svn.sourceforge.net/svnroot/opencvlibrary/tags/latest_tested_snapshot - CXCORE, CV, CVAUX: * CXCORE now uses Lapack (CLapack 3.1.1.1 in OpenCV 2.0) in its various linear algebra functions (such as solve, invert, SVD, determinant, eigen etc.) and the corresponding old-style functions (cvSolve, cvInvert etc.) * Lots of new feature and object detectors and descriptors have been added (there is no documentation on them yet), see cv.hpp and cvaux.hpp: + FAST - the fast corner detector, submitted by Edward Rosten + MSER - maximally stable extremal regions, submitted by Liu Liu + LDetector - fast circle-based feature detector by V. Lepetit (a.k.a. YAPE) + Fern-based point classifier and the planar object detector - based on the works by M. Ozuysal and V. Lepetit + One-way descriptor - a powerful PCA-based feature descriptor, (S. Hinterstoisser, O. Kutter, N. Navab, P. Fua, and V. Lepetit, "Real-Time Learning of Accurate Patch Rectification"). Contributed by Victor Eruhimov + Spin Images 3D feature descriptor - based on the A. Johnson PhD thesis; implemented by Anatoly Baksheev + Self-similarity features - contributed by Rainer Leinhart + HOG people and object detector - the reimplementation of Navneet Dalal framework (http://pascal.inrialpes.fr/soft/olt/). Currently, only the detection part is ported, but it is fully compatible with the original training code. See cvaux.hpp and opencv/samples/c/peopledetect.cpp. + Extended variant of the Haar feature-based object detector - implemented by Maria Dimashova. It now supports Haar features and LBPs (local binary patterns); other features can be more or less easily added + Adaptive skin detector and the fuzzy meanshift tracker - contributed by Farhad Dadgostar, see cvaux.hpp and opencv/samples/c/adaptiveskindetector.cpp * The new traincascade application complementing the new-style HAAR+LBP object detector has been added. See opencv/apps/traincascade. * The powerful library for approximate nearest neighbor search FLANN by Marius Muja is now shipped with OpenCV, and the OpenCV-style interface to the library is included into cxcore. See cxcore.hpp and opencv/samples/c/find_obj.cpp * The bundle adjustment engine has been contributed by PhaseSpace; see cvaux.hpp * Added dense optical flow estimation function (based on the paper "Two-Frame Motion Estimation Based on Polynomial Expansion" by G. Farnerback). See cv::calcOpticalFlowFarneback and the C++ documentation * Image warping operations (resize, remap, warpAffine, warpPerspective) now all support bicubic and Lanczos interpolation. * Most of the new linear and non-linear filtering operations (filter2D, sepFilter2D, erode, dilate ...) support arbitrary border modes and can use the valid image pixels outside of the ROI (i.e. the ROIs are not "isolated" anymore), see the C++ documentation. * The data can now be saved to and loaded from GZIP-compressed XML/YML files, e.g.: cvSave("a.xml.gz", my_huge_matrix); - MLL: * Added the Extremely Random Trees that train super-fast, comparing to Boosting or Random Trees (by Maria Dimashova). * The decision tree engine and based on it classes (Decision Tree itself, Boost, Random Trees) have been reworked and now: + they consume much less memory (up to 200% savings) + the training can be run in multiple threads (when OpenCV is built with OpenMP support) + the boosting classification on numerical variables is especially fast because of the specialized low-overhead branch. * mltest has been added. While far from being complete, it contains correctness tests for some of the MLL classes. - HighGUI: * [Linux] The support for stereo cameras (currently Videre only) has been added. There is now uniform interface for capturing video from two-, three- ... n-head cameras. * Images can now be compressed to or decompressed from buffers in the memory, see the C++ HighGUI reference manual - Documentation: * The reference manual has been converted from HTML to LaTeX (by James Bowman and Caroline Pantofaru), so there is now: + opencv.pdf for reading offline + and the online up-to-date documentation (as the result of LaTeX->Sphinx->HTML conversion) available at
http://opencv.willowgarage.com/documentation/index.html

– Samples, misc.:
* Better eye detector has been contributed by Shiqi Yu,
see opencv/data/haarcascades/*[lefteye|righteye]*.xml
* sample LBP cascade for the frontal face detection
has been created by Maria Dimashova,
see opencv/data/lbpcascades/lbpcascade_frontalface.xml
* Several high-quality body parts and facial feature detectors
have been contributed by Modesto Castrillon-Santana,
see opencv/data/haarcascades/haarcascade_mcs*.xml

>>> Optimization:
* Many of the basic functions and the image processing operations
(like arithmetic operations, geometric image transformations, filtering etc.)
have got SSE2 optimization, so they are several times faster.

– The model of IPP support has been changed. Now IPP is supposed to be
detected by CMake at the configuration stage and linked against OpenCV.
(In the beta it is not implemented yet though).

* PNG encoder performance improved by factor of 4 by tuning the parameters

>>> Bug fixes: <<< TBD (see http://sourceforge.net/tracker/?group_id=22870&atid=376677 of the list of the closed and still opened bugs). Many thanks to everybody who submitted bug reports and/or provided the patches! >>> Known issues:
* configure+autotools based build is currently broken.
Please, use CMake.
* OpenCV bug tracker at SF still lists about 150 open bugs.
Some of them may be actually fixed already, and most of the remaining bugs
are going to be fixed by OpenCV 2.0 gold.
* IPP is not supported. As the new OpenCV includes a lot of SSE2 code,
it may be not such a serious problem, though.
The support (at least for most important functions that do not have
SSE2 optimization) will be returned in 2.0 gold.
* The documentation has been updated and improved a lot, but it still
needs quite a bit of work:
– some of the new functionality in cvaux is not described yet.
– the bibliography part is broken
– there are quite a few known bugs and typos there
– many of the hyperlinks are not working.
* The existing tests partly cover the new functionality
(via the old backward-compatibility OpenCV 1.x API), but the coverage is
not sufficient of course.
* The new-style Python interface is not included yet

Many of the problems will be addressed in 2.0 gold.
If you have found some specific problem, please, put the record to the bug tracker:
http://sourceforge.net/tracker/?group_id=22870
Better if the bug reports will include a small code sample in C++/python +
all the necessary data files needed to reproduce the problem.

これに説明を書こうと思ったけど,変更が多すぎて大変そうなので
今回はインストール周りの注意点だけ書いてみます.

■(デフォルト)インストールディレクトリの変更

従来:C:\Program Files\OpenCV
OpenCV 2.0 beta:C:\Program Files\OpenCV1.2

個人的には
・バージョンがなぜ1.2なのか(OpenCV 1.2にしようとした名残??)
・なぜインストールディレクトリ名を変更したのか
が気になるところ.

■インクルードパスの変更
OpenCV 2.0 betaでは必要なヘッダが一つのディレクトリにまとまっています.
そのため,インクルードパスとしては下記のパス一つだけ指定すればOK.
これは地味にうれしい.

C:\Program Files\OpenCV1.2\include\opencv

ただし,従来のインクルードパスとは異なるので,
Visual Studioの設定変更が必要となります.

■ライブラリパスの変更

従来:C:\Program Files\OpenCV\lib
OpenCV 2.0 beta:C:\Program Files\OpenCV1.2\lib

従来のライブラリパスとは異なるので,
Visual Studioの設定変更が必要となります.

■ライブラリ名の変更

従来:cv.lib
OpenCV 2.0 beta:cv120.lib

ライブラリ名が変わっているので,ソース中で

#pragma comment(lib,”cv.lib”)

としている場合にはライブラリ名の修正が必要になります.

■ライブラリビルド方法変更
従来のOpenCVはVisual Studioのソリューションファイルが
提供されていましたが,OpenCV 2.0 betaからCmakeを用いて
Visual Studioのソリューションファイルを生成し,ライブラリを
ビルドする必要があります.

以前書いたOpenCV/SVN版 OpenCVビルド – Point at infinity
Cmakeを使ったビルド部分を参考にすることでビルドが可能です.
(※指定パスを変更する必要あり)

その他にもディレクトリ構成がかなり変更されていますが,
それは別の機会にでも。。。

ということで正式版が出るまでしばらく遊んでみようかなーと.

「詳解 OpenCV」レビュー

レビュー遅くなってゴメンナサイ。。。
オライリー様より「詳解 OpenCV」を献本頂いたのでレビューしたいと思います.

■帯コメント
OpenCVの開発者Gary Bradskiさんと某アニメの監督がコメントされてます.
気になる人は書店等で手にとって確認してみて下さい.
上記の写真は帯を外して撮りました(笑)

■原著(英語版)との違い
日本語版オリジナル記事として以下の2つが追加されています.

(1) iPhoneへの移植,高速化のための最適化手法

個人的にiPhoneアプリの一開発者としてこの記事だけのために
この本買ってもいいんじゃないかなーと思うくらい有益な内容が載ってます.

この記事ではFaceDetectionをターゲットとして,チューニングテクニックが
紹介されていますが,OpenCVだけに限らずiPhoneアプリのチューニングに
使えそうな内容.

そして半年の月日が流れ、、、「詳細 OpenCv」に寄稿しました My life as an APE
によるとFaceDetectionに高速化を施すと高速化前に比べて3倍くらい速くなったらしい(笑)

(2) 「Webカメラで手や物体を感知するディスプレイ」製作
Pipe Renderさんによるレーザー水平器を用いたマルチタッチディスプレイ製作
工学ナビさんによる偏光板を応用したディスプレイ製作
というOpenCVを使って作ってみた系の記事.

偏光板ネタはコンピュータビジョン・拡張現実感に関する普通じゃない勉強会 2.0
で橋本さんが発表されたものですね.

■他のOpenCV書籍との違い
2009年8月現在,日本語で読めるOpenCVの書籍は,
・OpenCV プログラミングブック
・実践OpenCV―映像処理&解析
だと思いますが,本のボリュームが明らかに違います.

OpenCV プログラミングブック:496ページ
実践OpenCV―映像処理&解析:275ページ

詳解 OpenCV:640ページ

というわけでページ数が多いので,チェックする側は苦労したという(以下略)

他の書籍に比べて理論的な部分について数式を交えて網羅的に書かれているので,
結構ボリュームになってます.その分,学生の画像処理の教本としても使えるし,
研究者として最低限押さえておくべき知識も得られるという割と広いレンジで
使える本になってるのかなと(若干値が張りますが。。。).

また,OpenCVの開発者が書いたと言うこともあって,アルゴリズムを単純に
実装するとパフォーマンス出ないので実装上こういう工夫してるよーとか
OpenCVの一部の関数名に付いている謎の2の理由とかも書かれてます.
#やっぱりあの2はそういう意味だったんかい!!って思ったり.

なので,OpenCVをディープなレベルで使い倒したい人にもオススメ.

■OpenCV 1.1対応?
英語の原著がOpenCV 1.0ベースで書かれているため,
「詳解 OpenCV」もOpenCV 1.0ベースの記述です.
#なので,OpenCV 1.1で追加されたSURF等の話は載ってません.

まぁ,基本的な仕組みは大きく変わらないのでそこまで困らないのかなと

■どんな人にオススメ?
・画像処理を使って何か面白いものをつくろうと画策しているGeekな方
・研究,仕事でOpenCV使うことになっちゃった人
・OpenCVを本気で使い倒したい人(学生,社会人)
・iPhoneアプリで画像処理やりたい人
・iPhoneアプリでチューニングのやり方を知りたい人

■他の方のレビューまとめ
hirax.net::inside out::読めばワクワク楽しくなる「詳解 OpenCV」
詳解 OpenCV – 将来が不安
オライリー 詳解 OpenCV | My Codex Leicester
elevenido: 「詳解 OpenCV」レビュー

ということで今日はこの位で締めたいと思います.気付いたら随時追記していきます.