記載するのが遅くなったが、昨年に続き今年も2つの記事をエントリーしたので、興味があったら、見てほしい。
OpenCVで顔向き推定を行う
OpenCVとdarknetを連携させてみた
OpenCV、機械学習、はやりのDeep learningの環境構築の方法、サンプルの動かし方、APIの使い方、Tipsなどをすぐに忘れてしまうので、備忘録として記録している。記憶がなくなるスピードが、早いのでメモしておかないと再現できなくなる確率が高まっている。 最近、再度HDDを飛ばしてしまい、過去の自分のページに再度助けられた。 また、DNNモジュールを触る機会が増えているので、C++からPyhonへと鞍替え中。 内容を気にいっていただければ、twitterで紹介願います。
2016年12月20日火曜日
2016年9月20日火曜日
RASPBIAN JESSIE に OpenCV が含まれていた
「RASPBIAN JESSIE に OpenCVが含まれているのでは」 では推測でしかなかったが、別途 RASPBIAN JESSIE 2016-5版 のSDカードを作成し、起動直後に /usr/lib/arm-linux-gnueabihf のフォルダーを見てみると、OpenCV 2.4.9 の共有ライブラリが存在していることが確認された。
これでホストPCでクロスコンパイルした ARM 版 OpenCV のアプリは、Raspberry Pi3 でそのまま動くと思われる。
g++ -o hoge hoge.cpp `pkg-config --cflags opencv` `pkg-config --libs opencv`
残念ながらこちらは、
pkg-config --cflags opencv
Package opencv was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv.pc'
to the PKG_CONFIG_PATH environment variable
No package 'opencv' found
となり、パッケージまでは準備されていなかった。
libに対応するinludeの中は、
ls /usr/include/arm-linux-gnueabihf/
a.out.h asm bits c++ expat_config.h fpu_control.h gnu ieee754.h python3.4m sys zconf.h
であり、OpenCVのincludeファイルは存在していない。
アプリのビルド方法は継続調査を行う
これでホストPCでクロスコンパイルした ARM 版 OpenCV のアプリは、Raspberry Pi3 でそのまま動くと思われる。
アプリのビルド
Raspberry Pi3上で、以下のように OpenCV のアプリのビルドを試みてた。g++ -o hoge hoge.cpp `pkg-config --cflags opencv` `pkg-config --libs opencv`
残念ながらこちらは、
pkg-config --cflags opencv
Package opencv was not found in the pkg-config search path.
Perhaps you should add the directory containing `opencv.pc'
to the PKG_CONFIG_PATH environment variable
No package 'opencv' found
となり、パッケージまでは準備されていなかった。
libに対応するinludeの中は、
ls /usr/include/arm-linux-gnueabihf/
a.out.h asm bits c++ expat_config.h fpu_control.h gnu ieee754.h python3.4m sys zconf.h
であり、OpenCVのincludeファイルは存在していない。
アプリのビルド方法は継続調査を行う
Raspberry Pi 3 で OpenCVの自作ベンチマークを比較した
RASPBIAN JESSIEで自前のOpenCVを利用するには で 2.4.13.1 with tbb の OpenCVを利用できるようになった。そこで、2.4.9.1 without tbb との自作のベンチマークを比較してみた。
実行時間は、各関数20回実行させたものの平均時間 msecを求めている。
また、参考までに、raspberry pi 2 の 2.4.11 with tbb のものも上げておく
黄色のセルは、tbbにより並列化の恩恵が大きい関数を示している。
tbbが有効な関数を使用しないのであれば、デフォルトの2.4.9.1でも問題ないと思う。
以上
実行時間は、各関数20回実行させたものの平均時間 msecを求めている。
また、参考までに、raspberry pi 2 の 2.4.11 with tbb のものも上げておく
右 Pi3 2.4.13.1 with tbb
中 Pi3 2.4.9.1 without tbb
左 Pi2 2.4.11 with tbb
黄色のセルは、tbbにより並列化の恩恵が大きい関数を示している。
tbbが有効な関数を使用しないのであれば、デフォルトの2.4.9.1でも問題ないと思う。
以上
RASPBIAN JESSIEで自前のOpenCVを利用するには
RASPBIAN JESSIE の OpenCV に関して の解決編
OpenCVの有名な関数であるcv::CascadeClassifierが並列化されていないため、処理時間が長い。原因は、アプリケーション共有ライブラリがうまくリンクされていないためと思われる。
(この問題に関しては既視感があったことは解決後に気づいた)
それゆえ、/usr/lib/arm-linux-gnueabihf/が、/usr/local/libの前に探索され、2.4.9.1がリンクされるためである。
export LD_LIBRARY_PATH=/usr/local/lib
を実行することで、探索順番を変えることができる。
.bashrcに書いておくのがベター
ldd cvbench
linux-vdso.so.1 (0x7ef38000)
/usr/lib/arm-linux-gnueabihf/libarmmem.so (0x76efd000)
libopencv_calib3d.so.2.4 => /usr/local/lib/libopencv_calib3d.so.2.4 (0x76e34000)
libopencv_contrib.so.2.4 => /usr/local/lib/libopencv_contrib.so.2.4 (0x76d58000)
libopencv_core.so.2.4 => /usr/local/lib/libopencv_core.so.2.4 (0x76af7000)
libopencv_features2d.so.2.4 => /usr/local/lib/libopencv_features2d.so.2.4 (0x76a4e000)
libopencv_flann.so.2.4 => /usr/local/lib/libopencv_flann.so.2.4 (0x769df000)
libopencv_highgui.so.2.4 => /usr/local/lib/libopencv_highgui.so.2.4 (0x7689f000)
libopencv_imgproc.so.2.4 => /usr/local/lib/libopencv_imgproc.so.2.4 (0x76605000)
libopencv_legacy.so.2.4 => /usr/local/lib/libopencv_legacy.so.2.4 (0x76500000)
libopencv_ml.so.2.4 => /usr/local/lib/libopencv_ml.so.2.4 (0x76472000)
libopencv_nonfree.so.2.4 => /usr/local/lib/libopencv_nonfree.so.2.4 (0x76449000)
libopencv_objdetect.so.2.4 => /usr/local/lib/libopencv_objdetect.so.2.4 (0x763ca000)
libopencv_photo.so.2.4 => /usr/local/lib/libopencv_photo.so.2.4 (0x7639d000)
libopencv_stitching.so.2.4 => /usr/local/lib/libopencv_stitching.so.2.4 (0x76322000)
libopencv_superres.so.2.4 => /usr/local/lib/libopencv_superres.so.2.4 (0x762f3000)
libopencv_video.so.2.4 => /usr/local/lib/libopencv_video.so.2.4 (0x76294000)
libopencv_videostab.so.2.4 => /usr/local/lib/libopencv_videostab.so.2.4 (0x7624f000)
OpenCVの有名な関数であるcv::CascadeClassifierが並列化されていないため、処理時間が長い。原因は、アプリケーション共有ライブラリがうまくリンクされていないためと思われる。
(この問題に関しては既視感があったことは解決後に気づいた)
原因
Linuxの共有ライブラリには、探索順番があり、アルファベット順とのことそれゆえ、/usr/lib/arm-linux-gnueabihf/が、/usr/local/libの前に探索され、2.4.9.1がリンクされるためである。
解決方法
ターミナルで、アプリケーション実行前にexport LD_LIBRARY_PATH=/usr/local/lib
を実行することで、探索順番を変えることができる。
.bashrcに書いておくのがベター
結果
実行後、ldd リンクで確認すると所望のものに変更されている。ldd cvbench
linux-vdso.so.1 (0x7ef38000)
/usr/lib/arm-linux-gnueabihf/libarmmem.so (0x76efd000)
libopencv_calib3d.so.2.4 => /usr/local/lib/libopencv_calib3d.so.2.4 (0x76e34000)
libopencv_contrib.so.2.4 => /usr/local/lib/libopencv_contrib.so.2.4 (0x76d58000)
libopencv_core.so.2.4 => /usr/local/lib/libopencv_core.so.2.4 (0x76af7000)
libopencv_features2d.so.2.4 => /usr/local/lib/libopencv_features2d.so.2.4 (0x76a4e000)
libopencv_flann.so.2.4 => /usr/local/lib/libopencv_flann.so.2.4 (0x769df000)
libopencv_highgui.so.2.4 => /usr/local/lib/libopencv_highgui.so.2.4 (0x7689f000)
libopencv_imgproc.so.2.4 => /usr/local/lib/libopencv_imgproc.so.2.4 (0x76605000)
libopencv_legacy.so.2.4 => /usr/local/lib/libopencv_legacy.so.2.4 (0x76500000)
libopencv_ml.so.2.4 => /usr/local/lib/libopencv_ml.so.2.4 (0x76472000)
libopencv_nonfree.so.2.4 => /usr/local/lib/libopencv_nonfree.so.2.4 (0x76449000)
libopencv_objdetect.so.2.4 => /usr/local/lib/libopencv_objdetect.so.2.4 (0x763ca000)
libopencv_photo.so.2.4 => /usr/local/lib/libopencv_photo.so.2.4 (0x7639d000)
libopencv_stitching.so.2.4 => /usr/local/lib/libopencv_stitching.so.2.4 (0x76322000)
libopencv_superres.so.2.4 => /usr/local/lib/libopencv_superres.so.2.4 (0x762f3000)
libopencv_video.so.2.4 => /usr/local/lib/libopencv_video.so.2.4 (0x76294000)
libopencv_videostab.so.2.4 => /usr/local/lib/libopencv_videostab.so.2.4 (0x7624f000)
RASPBIAN JESSIE の OpenCV に関して
RASPBIAN JESSIE の2016/5 月版に OpenCV2.4.9.1 が含まれているようであり、自ビルド版ではなく、こちらが有効になっている。
lddでリンク状態を見てみると以下のようになる。
opencvの共有ライブラリは、/usr/lib/arm-linux-gnueabihf/ のものが使用されている。
デフォルトで OpenCV をビルドするとインストール先は、/usr/local/lib である。たしかに、/usr/local/lib には、OpenCV のライブラリは存在しているが、利用されていないようである。
続く
ldd cvbench
linux-vdso.so.1 (0x7edab000)
/usr/lib/arm-linux-gnueabihf/libarmmem.so (0x76efe000)
libopencv_calib3d.so.2.4 => /usr/lib/arm-linux-gnueabihf/libopencv_calib3d.so.2.4 (0x76e5a000)
libopencv_contrib.so.2.4 => /usr/lib/arm-linux-gnueabihf/libopencv_contrib.so.2.4 (0x76d8a000)
libopencv_core.so.2.4 => /usr/lib/arm-linux-gnueabihf/libopencv_core.so.2.4 (0x76b71000)
libopencv_features2d.so.2.4 => /usr/lib/arm-linux-gnueabihf/libopencv_features2d.so.2.4 (0x76acf000)
libopencv_flann.so.2.4 => /usr/lib/arm-linux-gnueabihf/libopencv_flann.so.2.4 (0x76a64000)
libopencv_highgui.so.2.4 => /usr/lib/arm-linux-gnueabihf/libopencv_highgui.so.2.4 (0x76a12000)
libopencv_imgproc.so.2.4 => /usr/lib/arm-linux-gnueabihf/libopencv_imgproc.so.2.4 (0x767c4000)
libopencv_legacy.so.2.4 => /usr/lib/arm-linux-gnueabihf/libopencv_legacy.so.2.4 (0x766c8000)
libopencv_ml.so.2.4 => /usr/lib/arm-linux-gnueabihf/libopencv_ml.so.2.4 (0x7664a000)
libopencv_nonfree.so.2.4 => /usr/local/lib/libopencv_nonfree.so.2.4 (0x76621000)
libopencv_objdetect.so.2.4 => /usr/lib/arm-linux-gnueabihf/libopencv_objdetect.so.2.4 (0x765a5000)
libopencv_photo.so.2.4 => /usr/local/lib/libopencv_photo.so.2.4 (0x76578000)
libopencv_stitching.so.2.4 => /usr/local/lib/libopencv_stitching.so.2.4 (0x764fd000)
libopencv_superres.so.2.4 => /usr/local/lib/libopencv_superres.so.2.4 (0x764ce000)
libopencv_video.so.2.4 => /usr/lib/arm-linux-gnueabihf/libopencv_video.so.2.4 (0x76474000)
libopencv_videostab.so.2.4 => /usr/local/lib/libopencv_videostab.so.2.4 (0x7642f000)
lddでリンク状態を見てみると以下のようになる。
opencvの共有ライブラリは、/usr/lib/arm-linux-gnueabihf/ のものが使用されている。
デフォルトで OpenCV をビルドするとインストール先は、/usr/local/lib である。たしかに、/usr/local/lib には、OpenCV のライブラリは存在しているが、利用されていないようである。
続く
ldd cvbench
linux-vdso.so.1 (0x7edab000)
/usr/lib/arm-linux-gnueabihf/libarmmem.so (0x76efe000)
libopencv_calib3d.so.2.4 => /usr/lib/arm-linux-gnueabihf/libopencv_calib3d.so.2.4 (0x76e5a000)
libopencv_contrib.so.2.4 => /usr/lib/arm-linux-gnueabihf/libopencv_contrib.so.2.4 (0x76d8a000)
libopencv_core.so.2.4 => /usr/lib/arm-linux-gnueabihf/libopencv_core.so.2.4 (0x76b71000)
libopencv_features2d.so.2.4 => /usr/lib/arm-linux-gnueabihf/libopencv_features2d.so.2.4 (0x76acf000)
libopencv_flann.so.2.4 => /usr/lib/arm-linux-gnueabihf/libopencv_flann.so.2.4 (0x76a64000)
libopencv_highgui.so.2.4 => /usr/lib/arm-linux-gnueabihf/libopencv_highgui.so.2.4 (0x76a12000)
libopencv_imgproc.so.2.4 => /usr/lib/arm-linux-gnueabihf/libopencv_imgproc.so.2.4 (0x767c4000)
libopencv_legacy.so.2.4 => /usr/lib/arm-linux-gnueabihf/libopencv_legacy.so.2.4 (0x766c8000)
libopencv_ml.so.2.4 => /usr/lib/arm-linux-gnueabihf/libopencv_ml.so.2.4 (0x7664a000)
libopencv_nonfree.so.2.4 => /usr/local/lib/libopencv_nonfree.so.2.4 (0x76621000)
libopencv_objdetect.so.2.4 => /usr/lib/arm-linux-gnueabihf/libopencv_objdetect.so.2.4 (0x765a5000)
libopencv_photo.so.2.4 => /usr/local/lib/libopencv_photo.so.2.4 (0x76578000)
libopencv_stitching.so.2.4 => /usr/local/lib/libopencv_stitching.so.2.4 (0x764fd000)
libopencv_superres.so.2.4 => /usr/local/lib/libopencv_superres.so.2.4 (0x764ce000)
libopencv_video.so.2.4 => /usr/lib/arm-linux-gnueabihf/libopencv_video.so.2.4 (0x76474000)
libopencv_videostab.so.2.4 => /usr/local/lib/libopencv_videostab.so.2.4 (0x7642f000)
2016年9月19日月曜日
RASPBIAN JESSIE に OpenCVが含まれているのでは
Raspberry Pi3 でOpenCV 2.4.13.1をビルドし、自作のOpenCVベンチマークプログラムを実行させてみた。
HaarLike実行中に、CPUの負荷を見ていると25%になっており、計算時間も予想より長くなっていた。
並列化が行われていないようなので、tbb周りを見てみるが、ビルド環境は従来通りで、おかしいところはないと思わる。
何度もビルドしてみたが、ビルド時のcmakeの情報を見てみるとtbbは有効になっている。
そこで、ベンチマーク実行時にconfigrationを出力させてみるので見てみた。
なぜかOpenCV 2.4.9.1 となっている。自分では、2.4.9.1などインストールしていないので、最初から含まれている可能性がある。
General configuration for OpenCV 2.4.9.1 =====================================
Version control: unknown
Platform:
Host: Linux 3.19.0-trunk-armmp armv7l
CMake: 3.0.2
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.9.2)
C++ flags (Release): -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -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 -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -DNDEBUG
C++ flags (Debug): -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -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 -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -g -O0 -DDEBUG -D_DEBUG
C Compiler: /usr/bin/cc
C flags (Release): -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -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 -Wno-narrowing -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -DNDEBUG
C flags (Debug): -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -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 -Wno-narrowing -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -g -O0 -DDEBUG -D_DEBUG
Linker flags (Release): -Wl,-z,relro -Wl,-z,now -Wl,-z,relro -Wl,-z,now
Linker flags (Debug): -Wl,-z,relro -Wl,-z,now
Precompiled headers: YES
OpenCV modules:
To be built: core flann imgproc highgui features2d calib3d ml objdetect video contrib legacy photo gpu java ocl python stitching superres ts videostab
Disabled: world
Disabled by dependency: -
Unavailable: androidcamera dynamicuda viz
GUI:
QT: NO
GTK+ 2.x: YES (ver 2.24.25)
GThread : YES (ver 2.42.1)
GtkGlExt: YES (ver 1.2.0)
OpenGL support: YES (/usr/lib/arm-linux-gnueabihf/libGLU.so /usr/lib/arm-linux-gnueabihf/libGL.so /usr/lib/arm-linux-gnueabihf/libSM.so /usr/lib/arm-linux-gnueabihf/libICE.so /usr/lib/arm-linux-gnueabihf/libX11.so /usr/lib/arm-linux-gnueabihf/libXext.so)
VTK support: NO
Media I/O:
ZLib: /usr/lib/arm-linux-gnueabihf/libz.so (ver 1.2.8)
JPEG: /usr/lib/arm-linux-gnueabihf/libjpeg.so (ver )
PNG: /usr/lib/arm-linux-gnueabihf/libpng.so (ver 1.2.50)
TIFF: /usr/lib/arm-linux-gnueabihf/libtiff.so (ver 42 - 4.0.3)
JPEG 2000: /usr/lib/arm-linux-gnueabihf/libjasper.so (ver 1.900.1)
OpenEXR: /usr/lib/arm-linux-gnueabihf/libImath.so /usr/lib/arm-linux-gnueabihf/libIlmImf.so /usr/lib/arm-linux-gnueabihf/libIex.so /usr/lib/arm-linux-gnueabihf/libHalf.so /usr/lib/arm-linux-gnueabihf/libIlmThread.so (ver 1.6.1)
Video I/O:
DC1394 1.x: NO
DC1394 2.x: YES (ver 2.2.3)
FFMPEG: YES
codec: YES (ver 56.1.0)
format: YES (ver 56.1.0)
util: YES (ver 54.3.0)
swscale: YES (ver 3.0.0)
gentoo-style: YES
GStreamer: NO
OpenNI: NO
OpenNI PrimeSensor Modules: NO
PvAPI: NO
GigEVisionSDK: NO
UniCap: NO
UniCap ucil: NO
V4L/V4L2: Using libv4l (ver 1.6.0)
XIMEA: NO
Xine: NO
Other third-party libraries:
Use IPP: NO
Use Eigen: YES (ver 3.2.2)
Use TBB: NO
Use OpenMP: NO
Use GCD NO
Use Concurrency NO
Use C=: NO
Use Cuda: NO
Use OpenCL: YES
OpenCL:
Version: dynamic
Use AMD FFT: NO
Use AMD BLAS: NO
Python:
Interpreter: /usr/bin/python2 (ver 2.7.9)
Libraries: /usr/lib/arm-linux-gnueabihf/libpython2.7.so (ver 2.7.9)
numpy: /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.8.2)
packages path: lib/python2.7/dist-packages
Java:
ant: /usr/bin/ant (ver 1.9.4)
JNI: /usr/lib/jvm/default-java/include /usr/lib/jvm/default-java/include /usr/lib/jvm/default-java/include
Java tests: NO
Documentation:
Build Documentation: YES
Sphinx: /usr/bin/sphinx-build (ver 1.2.3)
PdfLaTeX compiler: /usr/bin/pdflatex
Tests and samples:
Tests: NO
Performance tests: YES
C/C++ Examples: YES
Install path: /usr
HaarLike実行中に、CPUの負荷を見ていると25%になっており、計算時間も予想より長くなっていた。
並列化が行われていないようなので、tbb周りを見てみるが、ビルド環境は従来通りで、おかしいところはないと思わる。
何度もビルドしてみたが、ビルド時のcmakeの情報を見てみるとtbbは有効になっている。
そこで、ベンチマーク実行時にconfigrationを出力させてみるので見てみた。
なぜかOpenCV 2.4.9.1 となっている。自分では、2.4.9.1などインストールしていないので、最初から含まれている可能性がある。
以下にconfigurationを示す。
tbbがoffになっている。General configuration for OpenCV 2.4.9.1 =====================================
Version control: unknown
Platform:
Host: Linux 3.19.0-trunk-armmp armv7l
CMake: 3.0.2
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.9.2)
C++ flags (Release): -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -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 -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -DNDEBUG
C++ flags (Debug): -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -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 -Wno-narrowing -Wno-delete-non-virtual-dtor -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -g -O0 -DDEBUG -D_DEBUG
C Compiler: /usr/bin/cc
C flags (Release): -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -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 -Wno-narrowing -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -DNDEBUG
C flags (Debug): -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2 -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 -Wno-narrowing -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -g -O0 -DDEBUG -D_DEBUG
Linker flags (Release): -Wl,-z,relro -Wl,-z,now -Wl,-z,relro -Wl,-z,now
Linker flags (Debug): -Wl,-z,relro -Wl,-z,now
Precompiled headers: YES
OpenCV modules:
To be built: core flann imgproc highgui features2d calib3d ml objdetect video contrib legacy photo gpu java ocl python stitching superres ts videostab
Disabled: world
Disabled by dependency: -
Unavailable: androidcamera dynamicuda viz
GUI:
QT: NO
GTK+ 2.x: YES (ver 2.24.25)
GThread : YES (ver 2.42.1)
GtkGlExt: YES (ver 1.2.0)
OpenGL support: YES (/usr/lib/arm-linux-gnueabihf/libGLU.so /usr/lib/arm-linux-gnueabihf/libGL.so /usr/lib/arm-linux-gnueabihf/libSM.so /usr/lib/arm-linux-gnueabihf/libICE.so /usr/lib/arm-linux-gnueabihf/libX11.so /usr/lib/arm-linux-gnueabihf/libXext.so)
VTK support: NO
Media I/O:
ZLib: /usr/lib/arm-linux-gnueabihf/libz.so (ver 1.2.8)
JPEG: /usr/lib/arm-linux-gnueabihf/libjpeg.so (ver )
PNG: /usr/lib/arm-linux-gnueabihf/libpng.so (ver 1.2.50)
TIFF: /usr/lib/arm-linux-gnueabihf/libtiff.so (ver 42 - 4.0.3)
JPEG 2000: /usr/lib/arm-linux-gnueabihf/libjasper.so (ver 1.900.1)
OpenEXR: /usr/lib/arm-linux-gnueabihf/libImath.so /usr/lib/arm-linux-gnueabihf/libIlmImf.so /usr/lib/arm-linux-gnueabihf/libIex.so /usr/lib/arm-linux-gnueabihf/libHalf.so /usr/lib/arm-linux-gnueabihf/libIlmThread.so (ver 1.6.1)
Video I/O:
DC1394 1.x: NO
DC1394 2.x: YES (ver 2.2.3)
FFMPEG: YES
codec: YES (ver 56.1.0)
format: YES (ver 56.1.0)
util: YES (ver 54.3.0)
swscale: YES (ver 3.0.0)
gentoo-style: YES
GStreamer: NO
OpenNI: NO
OpenNI PrimeSensor Modules: NO
PvAPI: NO
GigEVisionSDK: NO
UniCap: NO
UniCap ucil: NO
V4L/V4L2: Using libv4l (ver 1.6.0)
XIMEA: NO
Xine: NO
Other third-party libraries:
Use IPP: NO
Use Eigen: YES (ver 3.2.2)
Use TBB: NO
Use OpenMP: NO
Use GCD NO
Use Concurrency NO
Use C=: NO
Use Cuda: NO
Use OpenCL: YES
OpenCL:
Version: dynamic
Use AMD FFT: NO
Use AMD BLAS: NO
Python:
Interpreter: /usr/bin/python2 (ver 2.7.9)
Libraries: /usr/lib/arm-linux-gnueabihf/libpython2.7.so (ver 2.7.9)
numpy: /usr/lib/python2.7/dist-packages/numpy/core/include (ver 1.8.2)
packages path: lib/python2.7/dist-packages
Java:
ant: /usr/bin/ant (ver 1.9.4)
JNI: /usr/lib/jvm/default-java/include /usr/lib/jvm/default-java/include /usr/lib/jvm/default-java/include
Java tests: NO
Documentation:
Build Documentation: YES
Sphinx: /usr/bin/sphinx-build (ver 1.2.3)
PdfLaTeX compiler: /usr/bin/pdflatex
Tests and samples:
Tests: NO
Performance tests: YES
C/C++ Examples: YES
Install path: /usr
Raspberry Pi 3 で OpenCV 2.4.13.1 をビルドした
久しぶりに更新
Raspberry Pi 2に関してはここ
最初にraspberry piを更新しておく
sudo rpi-update
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install -y libavcodec-dev libavformat-dev libswscale-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libgstreamer0.10-dev v4l-utils libv4l-dev libgstreamer-plugins-base0.10-dev
sudo apt-get install -y python-dev python-numpy libeigen3-dev
USB HDDをRaspberry Pi 3に接続する(USB HDDへの電源供給が不足しているとマウントされない)
2.4.13.1のフォルダーにbuildpi3を作成し、cd buildpi3
ビルド時間
real 41m55.667s
user 147m11.760s
sys 4m29.960s
sudo ldconfig
以上
Raspberry Pi 2に関してはここ
環境
RASPBIAN JESSIE 2016-05-27版を使用最初にraspberry piを更新しておく
sudo rpi-update
sudo apt-get update
sudo apt-get upgrade
OpenCVのbuildに必要なファイルのインストール
sudo apt-get install -y cmake libgtk2.0-devsudo apt-get install -y libavcodec-dev libavformat-dev libswscale-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libgstreamer0.10-dev v4l-utils libv4l-dev libgstreamer-plugins-base0.10-dev
sudo apt-get install -y python-dev python-numpy libeigen3-dev
ソースの準備
ホストPCでダウンロードした、OpenCV2.4.13.1のソースを展開して、外付けUSB HDDにコピーUSB HDDをRaspberry Pi 3に接続する(USB HDDへの電源供給が不足しているとマウントされない)
2.4.13.1のフォルダーにbuildpi3を作成し、cd buildpi3
CMAKEの実行
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 ..ビルド
time make -j4でビルドを行うビルド時間
real 41m55.667s
user 147m11.760s
sys 4m29.960s
インストール
sudo make installsudo ldconfig
以上
登録:
投稿 (Atom)


