2015年10月1日木曜日

OpenCV2.4.12.2がリリースされた


公式にはアナウンスされていないが、前回と同じくひっそりとOpenCV 2.4.12.2がリリースされている

今回もGitHubから取得しないといけない。

diffは見ていないが、bug fixがほとんどと思われる。

OpenCV 3.0で DNNを試してみた

1月前にOpenCV 3.0のcontribにdnnモジュールが追加された。


当初ubuntu版で試してみたが、importerのところで落ちてしまい原因がわからなかった。
issueでも同じ現象に遭遇している人がいたが、解決していない

twitterに成功したと書き込んでいる人がいたので、仕方なしにWindowsで試してみた

マシン環境
Windows7 64bit OpenCV 3.0 + contrib

開発環境
cmake 3.3.2 win32 x86
Visual studio community 2013

環境構築は、後で説明する。


無事OpenCVがビルドできたので、環境変数にpathを設定し、専用のpropatyシートを作成

サンプルは、
C:\opencv30\opencv_contrib-master\modules\dnn\samples
に一式あるので、内容をそのまま自分のプロジェクトにコピーし、時間計測関数を追加した。

モデルファイルは、容量が50Mを超えるため添付されていなく、自分でここから取得し、サンプルフォルダに置いた。

プロジェクトを実行したところubuntu版と異なり、無事結果を見ることができた。


うちのマシンでは、DNNの計算に180msecかかっている。

最適化を行えば、もう少し早くなるかもしれない。
ただ、このOpenCVは32bit版なので64bitで作成すれば、更なる短縮が見込めるかも知れない

以上

2015年9月2日水曜日

DeepDreamを試してみた

話題になった時期に試した見たが、文章は放置していたので時期遅れとなった。

caffeの動くマシンで

mkdir deepdream
cd deepdream

caffe用のモデルを取得

wget http://dl.caffe.berkeleyvision.org/bvlc_googlenet.caffemodel

 
deepdream用のipython notebookを取得

git clone https://github.com/google/deepdream


手元でipython notebookが動作する環境がなかったのでpythonのスクリプトを公開している人がいたので取得した

wget http://www.hirotakaster.com/download/dd.py

自分の環境にあわせて変更
 中間の状態の表示をカットし、100回適応後の画像をフォルダーに書き出す

CPU環境で実行したので処理速度は遅く、元画像にサイズの大きい画像を選ぶと処理時間が増大するので、1000画素より小さくしている




参考にしたページ

ODROID-XU3 Lite向けにOpenCV2.4.11をビルドした


書きかけで放置していたものだが忘れるといけないのでUPしておく

前回はここ

前回同様にHDDにOpenCV2.4.11のソースを展開しておき、USB HDDを接続すると
/mnt/odroidにマウントされる

opencv2411のフォルダーにmkdir buildodroidを作成し、buildodroidに移動
今回は、
apt-get install libeigen3-devで eigenをインストールしている

すでにraspberry pi2用にビルドしたあとなので、tbbはHDD内に存在している
今回は、ccmakeで指定したtbbのオプションが有効になっているようだ

NEONをONに、GPUは関係ないので外し、あとビルド時間短縮のために不要なものを外している

time cmake -j8 で8コアを指定してビルドしてみる

何か警告が出ている無視
Note: Class Feature2D has more than 1 base class (not supported by Python C extensions)
      Bases:  cv::FeatureDetector, cv::DescriptorExtractor
      Only the first base class will be used

real    12m17.741s
user    69m20.115s
sys    5m56.840s

以上

2015年8月26日水曜日

OpenCV2.4.12.1がリリースされた

公式にはアナウンスされていないがひっそりとOpenCV 2.4.12.1がリリースされている

これまでソースは、sourceforgeからダウンロードしたが、方針の変更によりGitHubからダウンロードする事になった。




ダウンロードのページ
最新のコミットは、12日前(8/16時点)




リリースノートが無いため、2.4.11との変更点は不明である
時間があれば軽く差分を見てみる予定

ちなみに2.4.12は、28日前なので、わずか2週間で修正版がリリースされたことになる

まだ、ソースしか提供されていないので、Windowsでは、自分でビルドしないといけない


すでに2.4.13も予定されている

2015年8月14日金曜日

Raspberry Pi 2 で OpenCV 2.4.11 をビルドした

久しぶりに更新
2.4.10に関してはここ

8/17 追記
3/4に 
Raspberry Pi 2 で OpenCV 2.4.11 をビルドした
というメモを書いていたのをすっかり忘れている
前回は、オプションの設定をccmakeで手動で行っているが、今回は引数で設定している
今回はtbbでトラブルことはなかった



最初にraspberry piを更新しておく

sudo rpi-update
sudo apt-get update
sudo apt-get upgrade

ホストPCでOpenCV2.4.11のソースをダウンロードし、展開して外付けHDDにコピー

USB HDDをRaspberry Pi 2に接続し、2.4.11のフォルダーにbuildpi2を作成し、cd buildpi2

OpenCVに必要なファイルは、2.4.10のときにインストールしているので、今回は何もしない

コンフィグレーションを設定

cmake -DCMAKE_BUILD_TYPE=RELEASE -DENABLE_VFPV3=ON -DENABLE_NEON=ON -DBUILD_DOCS=OFF -DBUILD_TESTS=off -DBUILD_PERF_TESTS=OFF -DBUILD_TBB=ON -DBUILD_opencv_apps=OFF -DBUILD_opencv_gpu=OFF -DWITH_OPENCL=off -DWITH_1394=off -DWITH_CUDA=OFF -DWITH_CUFFT=OFF -DWITH_GIGEAPI=OFF -DWITH_OPENCLAMDBLAS=off -DWITH_OPENCLAMDFFT=off -DWITH_TBB=ON ..

raspberry piではOpenCLがサポートされていないのでoffにしている

time make -j4でビルドを行う

real    51m17.127s
user    177m0.210s
sys    5m48.860s

以上

以下は、コンフィグレーション情報

General configuration for OpenCV 2.4.11 =====================================
  Version control:               unknown

  Platform:
    Host:                        Linux 3.18.11-v7+ armv7l
    CMake:                       2.8.9
    CMake generator:             Unix Makefiles
    CMake build tool:            /usr/bin/make
    Configuration:               RELEASE

  C/C++:
    Built as dynamic libs?:      YES
    C++ Compiler:                /usr/bin/c++  (ver 4.6.3)
    C++ flags (Release):         -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -fdiagnostics-show-option -pthread -fomit-frame-pointer -mfpu=neon -ffunction-sections -O3 -DNDEBUG  -DNDEBUG
    C++ flags (Debug):           -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -fdiagnostics-show-option -pthread -fomit-frame-pointer -mfpu=neon -ffunction-sections -g  -O0 -DDEBUG -D_DEBUG
    C Compiler:                  /usr/bin/gcc
    C flags (Release):           -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -fdiagnostics-show-option -pthread -fomit-frame-pointer -mfpu=neon -ffunction-sections -O3 -DNDEBUG  -DNDEBUG
    C flags (Debug):             -fsigned-char -W -Wall -Werror=return-type -Werror=address -Werror=sequence-point -Wformat -Werror=format-security -Wmissing-declarations -Wmissing-prototypes -Wstrict-prototypes -Wundef -Winit-self -Wpointer-arith -Wshadow -fdiagnostics-show-option -pthread -fomit-frame-pointer -mfpu=neon -ffunction-sections -g  -O0 -DDEBUG -D_DEBUG
    Linker flags (Release):    
    Linker flags (Debug):      
    Precompiled headers:         YES

  OpenCV modules:
    To be built:                 core flann imgproc highgui features2d calib3d ml nonfree objdetect video contrib legacy photo python stitching superres ts videostab
    Disabled:                    gpu world
    Disabled by dependency:      -
    Unavailable:                 androidcamera dynamicuda java ocl viz

  GUI:
    QT:                          NO
    GTK+ 2.x:                    YES (ver 2.24.10)
    GThread :                    YES (ver 2.40.0)
    GtkGlExt:                    NO
    OpenGL support:              NO
    VTK support:                 NO

  Media I/O:
    ZLib:                        /usr/lib/arm-linux-gnueabihf/libz.so (ver 1.2.7)
    JPEG:                        libjpeg (ver 62)
    PNG:                         /usr/lib/arm-linux-gnueabihf/libpng.so (ver 1.2.49)
    TIFF:                        build (ver 42 - 4.0.2)
    JPEG 2000:                   build (ver 1.900.1)
    OpenEXR:                     build (ver 1.7.1)

  Video I/O:
    DC1394 1.x:                  NO
    DC1394 2.x:                  NO
    FFMPEG:                      NO
      codec:                     NO
      format:                    NO
      util:                      NO
      swscale:                   NO
      gentoo-style:              NO
    GStreamer:                   NO
    OpenNI:                      NO
    OpenNI PrimeSensor Modules:  NO
    PvAPI:                       NO
    GigEVisionSDK:               NO
    UniCap:                      NO
    UniCap ucil:                 NO
    V4L/V4L2:                    NO/YES
    XIMEA:                       NO
    Xine:                        NO

  Other third-party libraries:
    Use IPP:                     NO
    Use Eigen:                   YES (ver 3.1.0)
    Use TBB:                     YES (ver 4.3 interface 8002)
    Use OpenMP:                  NO
    Use GCD                      NO
    Use Concurrency              NO
    Use C=:                      NO
    Use Cuda:                    NO
    Use OpenCL:                  NO

  Python:
    Interpreter:                 /usr/bin/python2 (ver 2.7.3)
    Libraries:                   /usr/lib/libpython2.7.so (ver 2.7.3)
    numpy:                       /usr/lib/pymodules/python2.7/numpy/core/include (ver 1.6.2)
    packages path:               lib/python2.7/dist-packages

  Java:
    ant:                         NO
    JNI:                         NO
    Java tests:                  NO

  Tests and samples:
    Tests:                       NO
    Performance tests:           NO
    C/C++ Examples:              NO

  Install path:                  /usr/local


2015年3月19日木曜日

Windows版 OpenCV 2.4.11のConfigurationを表示してみた

デフォルトで提供されているWindows版の2.4.11のコンフィグレーションを表示させてみた
TBBがONになっていないのは何気にいたい

(顔検出はTBBがONになっているとコア数分並列で計算されるので効果が大きい)

独自のベンチを試してみたらUbuntuのTBB ONのバージョンと時間はほぼ同じであった
ConcurrencyがONになっているので、並列計算が有効になっていると思われる


General configuration for OpenCV 2.4.11 =====================================
  Version control:               2.4.11

  Platform:
    Host:                        Windows 6.1 AMD64
    CMake:                       2.8.11.2
    CMake generator:             Visual Studio 12 Win64
    CMake build tool:            C:/PROGRA~2/MSBuild/12.0/Bin/MSBuild.exe
    MSVC:                        1800

  OpenCV modules:
    To be built:                 core flann imgproc highgui features2d calib3d ml video legacy objdetect photo gpu ocl nonfree contrib stitching superres ts videostab
    Disabled:                    java python world
    Disabled by dependency:      -
    Unavailable:                 androidcamera dynamicuda viz

  Windows RT support:            NO

  GUI:
    QT:                          NO
    Win32 UI:                    YES
    OpenGL support:              NO
    VTK support:                 NO

  Media I/O:
    ZLib:                        build (ver 1.2.7)
    JPEG:                        build (ver 62)
    PNG:                         build (ver 1.5.12)
    TIFF:                        build (ver 42 - 4.0.2)
    JPEG 2000:                   build (ver 1.900.1)
    OpenEXR:                     build (ver 1.7.1)

  Video I/O:
    Video for Windows:           YES
    DC1394 1.x:                  NO
    DC1394 2.x:                  NO
    FFMPEG:                      YES (prebuilt binaries)
      codec:                     YES (ver 55.18.102)
      format:                    YES (ver 55.12.100)
      util:                      YES (ver 52.38.100)
      swscale:                   YES (ver 2.3.100)
      gentoo-style:              YES
    OpenNI:                      NO
    OpenNI PrimeSensor Modules:  NO
    PvAPI:                       NO
    GigEVisionSDK:               NO
    DirectShow:                  YES
    Media Foundation:            NO
    XIMEA:                       NO
    Intel PerC:                  NO

  Other third-party libraries:
    Use IPP:                     NO
    Use Eigen:                   NO
    Use TBB:                     NO
    Use OpenMP:                  NO
    Use GCD                      NO
    Use Concurrency              YES
    Use C=:                      NO
    Use Cuda:                    NO
    Use OpenCL:                  YES

  OpenCL:
    Version:                     dynamic
    Include path:                C:/builds/2_4_PackSlave-win64-vc12-shared/opencv/3rdparty/include/opencl/1.2 C:/Program Files (x86)/AMD/clAmdFft/include C:/Program Files (x86)/AMD/clAmdBlas/include
    Use AMD FFT:                 YES
    Use AMD BLAS:                YES

  Python:
    Interpreter:                 C:/Python27-x64/python.exe (ver 2.7.5)

  Java:
    ant:                         C:/Program Files (x86)/apache-ant/bin/ant.bat (ver 1.9.2)
    JNI:                         C:/Program Files/Java/jdk1.6.0_45/include C:/Program Files/Java/jdk1.6.0_45/include/win32 C:/Program Files/Java/jdk1.6.0_45/include
    Java tests:                  NO

  Tests and samples:
    Tests:                       NO
    Performance tests:           NO
    C/C++ Examples:              NO