[[Jetson TK1でOpenCV3.1.0をビルド]]
#contents
*概要 [#n31d02c7]
-[[Jetson TX1]]を入手したので、OpenCVをビルドしてみた
*今回のターゲット [#sd5f12b1]
-Jetson TX1
-L4T (Ubuntu 16.04をベースにしたもの)
-Arm Cortex A57
-Tegra X1 (256 core)
-cmake 3.5.1
-CUDA 8.0
*OpenCV の取得 [#d181e443]
-まずはgitでcloneする
-詳細は割愛
-そして、3.1.0をチェックアウトする
ubuntu@tegra-ubuntu:~$ cd opencv
ubuntu@tegra-ubuntu:~/opencv$ git checkout -b Branch_3_1_0 3.1.0
Switched to a new branch 'Branch_3_1_0'
**手修正 [#rd081e53]
-OpenCV 3.1.0 ではCUDAのGraphCut モジュールを取り込むのだが、このモジュールはCUDA 7.5 でdeprecated に移動され、CUDA 8.0 から正式に除外された
-よって、OpenCV 3.1.0+CUDA 8.0のビルドは[[そのままでは失敗する>https://twitter.com/tomoaki_teshima/status/783097097071435777]]¬e{twitter-tomoaki-teshima-opencv310-cuda80:[[Tomoaki Teshimaさんのツイート: "CUDA 7.5 でGraphCutがdeprecatedになり...>https://twitter.com/tomoaki_teshima/status/783097097071435777]], 2016-10-04公開, 2016-10-26閲覧};
-そのままビルドすると、以下の様なエラーが多発する
modules/cudalegacy/src/graphcuts.cpp:120:54: error: ‘NppiGraphcutState’ has not been declared
typedef NppStatus (*init_func_t)(NppiSize oSize, NppiGraphcutState** ppState, Npp8u* pDeviceMem);
^
modules/cudalegacy/src/graphcuts.cpp:135:18: error: ‘NppiGraphcutState’ does not name a type
operator NppiGraphcutState*()
^
modules/cudalegacy/src/graphcuts.cpp:141:9: error: ‘NppiGraphcutState’ does not name a type
NppiGraphcutState* pState;
^
In file included from build/modules/cudalegacy/precomp.hpp:75:0:
modules/cudalegacy/src/graphcuts.cpp: In constructor‘{anonymous}::NppiGraphcutStateHandler::NppiGraphcutStateHandler(NppiSize, Npp8u*, {anonymous}::init_func_t)’:
modules/cudalegacy/src/graphcuts.cpp:127:39: error: ‘pState’ was not declared in this scope
-よって、 modules/cudalegacy/src/graphcuts.cpp の45行目に以下の修正が必要
#geshi(c++){{
-#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER)
+#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) || (CUDART_VERSION >= 8000)
}}
*OpenCV3.1.0のビルド [#f2c02faa]
-cmakeとmakeする
-cmakeのfull logは[[こちら>https://gist.github.com/tomoaki0705/e639c2f9bd8b4bd277910cf3daf6cbbe]]
-make allのfull logは[[こちら>https://gist.github.com/tomoaki0705/05f0502b7ed7c6e340748e8d9e1b082f]]
**cmake [#ya471945]
-[[ODROID-X2でOpenCV 3.1.0をビルド]]同様、out of source buildする
ubuntu@tegra-ubuntu:~/opencv$ mkdir build
ubuntu@tegra-ubuntu:~/opencv$ cd build/
ubuntu@tegra-ubuntu:~/opencv/build$ time cmake ..
(中略)
real 0m38.431s
user 0m22.440s
sys 0m6.110s
**make all [#t3a2f8b0]
-Armの4coreをフルに使う
ubuntu@tegra-ubuntu:~/opencv/build$ time make -j 4
(中略)
real 48m50.693s
user 164m25.770s
sys 7m48.100s
-ざっくり50分ぐらいかかる
*OpenCVビルド時のコンフィグなど [#ufa17ae8]
**cvconfig.h [#f00d1fb2]
#geshi(c++){{
/* OpenCV compiled as static or dynamic libs */
#define BUILD_SHARED_LIBS
/* Compile for 'real' NVIDIA GPU architectures */
#define CUDA_ARCH_BIN " 53"
/* Create PTX or BIN for 1.0 compute capability */
/* #undef CUDA_ARCH_BIN_OR_PTX_10 */
/* NVIDIA GPU features are used */
#define CUDA_ARCH_FEATURES " 53"
/* Compile for 'virtual' NVIDIA PTX architectures */
#define CUDA_ARCH_PTX ""
/* AVFoundation video libraries */
/* #undef HAVE_AVFOUNDATION */
/* V4L capturing support */
/* #undef HAVE_CAMV4L */
/* V4L2 capturing support */
#define HAVE_CAMV4L2
/* Carbon windowing environment */
/* #undef HAVE_CARBON */
/* AMD's Basic Linear Algebra Subprograms Library*/
/* #undef HAVE_CLAMDBLAS */
/* AMD's OpenCL Fast Fourier Transform Library*/
/* #undef HAVE_CLAMDFFT */
/* Clp support */
/* #undef HAVE_CLP */
/* Cocoa API */
/* #undef HAVE_COCOA */
/* C= */
/* #undef HAVE_CSTRIPES */
/* NVidia Cuda Basic Linear Algebra Subprograms (BLAS) API*/
/* #undef HAVE_CUBLAS */
/* NVidia Cuda Runtime API*/
#define HAVE_CUDA
/* NVidia Cuda Fast Fourier Transform (FFT) API*/
#define HAVE_CUFFT
/* IEEE1394 capturing support */
/* #undef HAVE_DC1394 */
/* IEEE1394 capturing support - libdc1394 v2.x */
/* #undef HAVE_DC1394_2 */
/* DirectX */
/* #undef HAVE_DIRECTX */
/* #undef HAVE_DIRECTX_NV12 */
/* #undef HAVE_D3D11 */
/* #undef HAVE_D3D10 */
/* #undef HAVE_D3D9 */
/* DirectShow Video Capture library */
/* #undef HAVE_DSHOW */
/* Eigen Matrix & Linear Algebra Library */
#define HAVE_EIGEN
/* FFMpeg video library */
/* #undef HAVE_FFMPEG */
/* ffmpeg's libswscale */
/* #undef HAVE_FFMPEG_SWSCALE */
/* ffmpeg in Gentoo */
/* #undef HAVE_GENTOO_FFMPEG */
/* Geospatial Data Abstraction Library */
/* #undef HAVE_GDAL */
/* GStreamer multimedia framework */
#define HAVE_GSTREAMER
/* GTK+ 2.0 Thread support */
#define HAVE_GTHREAD
/* GTK+ 2.x toolkit */
/* #undef HAVE_GTK */
/* Define to 1 if you have the <inttypes.h> header file. */
/* #undef HAVE_INTTYPES_H */
/* Intel Perceptual Computing SDK library */
/* #undef HAVE_INTELPERC */
/* Intel Integrated Performance Primitives */
/* #undef HAVE_IPP */
/* #undef HAVE_IPP_ICV_ONLY */
/* Intel IPP Async */
/* #undef HAVE_IPP_A */
/* JPEG-2000 codec */
#define HAVE_JASPER
/* IJG JPEG codec */
#define HAVE_JPEG
/* libpng/png.h needs to be included */
#define HAVE_LIBPNG_PNG_H
/* V4L/V4L2 capturing support via libv4l */
/* #undef HAVE_LIBV4L */
/* Microsoft Media Foundation Capture library */
/* #undef HAVE_MSMF */
/* NVidia Video Decoding API*/
/* #undef HAVE_NVCUVID */
/* OpenCL Support */
#define HAVE_OPENCL
/* #undef HAVE_OPENCL_STATIC */
/* #undef HAVE_OPENCL_SVM */
/* OpenEXR codec */
#define HAVE_OPENEXR
/* OpenGL support*/
/* #undef HAVE_OPENGL */
/* OpenNI library */
/* #undef HAVE_OPENNI */
/* OpenNI library */
/* #undef HAVE_OPENNI2 */
/* PNG codec */
#define HAVE_PNG
/* Posix threads (pthreads) */
#define HAVE_PTHREADS
/* parallel_for with pthreads */
#define HAVE_PTHREADS_PF
/* Qt support */
/* #undef HAVE_QT */
/* Qt OpenGL support */
/* #undef HAVE_QT_OPENGL */
/* QuickTime video libraries */
/* #undef HAVE_QUICKTIME */
/* QTKit video libraries */
/* #undef HAVE_QTKIT */
/* Intel Threading Building Blocks */
/* #undef HAVE_TBB */
/* TIFF codec */
#define HAVE_TIFF
/* Unicap video capture library */
/* #undef HAVE_UNICAP */
/* Video for Windows support */
/* #undef HAVE_VFW */
/* V4L2 capturing support in videoio.h */
/* #undef HAVE_VIDEOIO */
/* Win32 UI */
/* #undef HAVE_WIN32UI */
/* XIMEA camera support */
/* #undef HAVE_XIMEA */
/* Xine video library */
/* #undef HAVE_XINE */
/* Define if your processor stores words with the most significant byte
first (like Motorola and SPARC, unlike Intel and VAX). */
/* #undef WORDS_BIGENDIAN */
/* gPhoto2 library */
/* #undef HAVE_GPHOTO2 */
/* VA library (libva) */
/* #undef HAVE_VA */
/* Intel VA-API/OpenCL */
/* #undef HAVE_VA_INTEL */
}}
**version_string.inc [#q12dad2a]
-コードに修正を施したので、Version が3.1.0-dirtyになっている
General configuration for OpenCV 3.1.0 =====================================
Version control: 3.1.0-dirty
Platform:
Host: Linux 3.10.96-tegra aarch64
CMake: 3.5.1
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 5.4.0)
C++ flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -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 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG
C++ flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -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 -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG
C Compiler: /usr/bin/cc
C flags (Release): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -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 -fvisibility=hidden -O3 -DNDEBUG -DNDEBUG
C flags (Debug): -fsigned-char -W -Wall -Werror=return-type -Werror=non-virtual-dtor -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 -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG
Linker flags (Release):
Linker flags (Debug):
Precompiled headers: YES
Extra dependencies: /usr/lib/aarch64-linux-gnu/libpng.so /usr/lib/aarch64-linux-gnu/libz.so gthread-2.0 gstvideo-1.0 gstapp-1.0 gstbase-1.0 gstriff-1.0 gstpbutils-1.0 gstreamer-1.0 gobject-2.0 glib-2.0 dl m pthread rt cudart nppc nppi npps cufft -L/usr/local/cuda-8.0/lib64
3rdparty dependencies: libjpeg libwebp libtiff libjasper IlmImf
OpenCV modules:
To be built: cudev core cudaarithm flann imgproc ml video cudabgsegm cudafilters cudaimgproc cudawarping imgcodecs photo shape videoio cudacodec highgui objdetect ts features2d calib3d cudafeatures2d cudalegacy cudaobjdetect cudaoptflow cudastereo stitching superres videostab
Disabled: world
Disabled by dependency: -
Unavailable: java python2 python3 viz
GUI:
QT: NO
GTK+: NO
GThread : YES (ver 2.48.1)
GtkGlExt: NO
OpenGL support: NO
VTK support: NO
Media I/O:
ZLib: /usr/lib/aarch64-linux-gnu/libz.so (ver 1.2.8)
JPEG: libjpeg (ver 90)
WEBP: build (ver 0.3.1)
PNG: /usr/lib/aarch64-linux-gnu/libpng.so (ver 1.2.54)
TIFF: build (ver 42 - 4.0.2)
JPEG 2000: build (ver 1.900.1)
OpenEXR: build (ver 1.7.1)
GDAL: NO
Video I/O:
DC1394 1.x: NO
DC1394 2.x: NO
FFMPEG: NO
codec: NO
format: NO
util: NO
swscale: NO
resample: NO
gentoo-style: NO
GStreamer:
base: YES (ver 1.8.2)
video: YES (ver 1.8.2)
app: YES (ver 1.8.2)
riff: YES (ver 1.8.2)
pbutils: YES (ver 1.8.2)
OpenNI: NO
OpenNI PrimeSensor Modules: NO
OpenNI2: NO
PvAPI: NO
GigEVisionSDK: NO
UniCap: NO
UniCap ucil: NO
V4L/V4L2: NO/YES
XIMEA: NO
Xine: NO
gPhoto2: NO
Parallel framework: pthreads
Other third-party libraries:
Use IPP: NO
Use VA: NO
Use Intel VA-API/OpenCL: NO
Use Eigen: YES (ver 3.2.92)
Use Cuda: YES (ver 8.0)
Use OpenCL: YES
Use custom HAL: NO
NVIDIA CUDA
Use CUFFT: YES
Use CUBLAS: NO
USE NVCUVID: NO
NVIDIA GPU arch: 53
NVIDIA PTX archs:
Use fast math: NO
OpenCL:
Version: dynamic
Include path: /home/ubuntu/opencv-fork/3rdparty/include/opencl/1.2
Use AMDFFT: NO
Use AMDBLAS: NO
Python 2:
Interpreter: /usr/bin/python2.7 (ver 2.7.12)
Python 3:
Interpreter: /usr/bin/python3 (ver 3.5.2)
Python (for build): /usr/bin/python2.7
Java:
ant: NO
JNI: NO
Java wrappers: NO
Java tests: NO
Matlab: Matlab not found or implicitly disabled
Documentation:
Doxygen: NO
PlantUML: NO
Tests and samples:
Tests: YES
Performance tests: YES
C/C++ Examples: NO
Install path: /usr/local
cvconfig.h is in: /home/ubuntu/opencv-fork/build
-----------------------------------------------------------------
*ビルドされたライブラリや実行ファイル [#m8dc987b]
-TBW
*performance [#l2fb0abe]
-TBW
*関連ページ [#jf4c78b6]
-[[:OpenCV]]
-[[:OpenCV 3.0]]
-[[:OpenCV 3.1]]
-[[Jetson TK1]]
-[[Jetson TK1でOpenCV3.0.0-beta]]
-[[Jetson TK1でOpenCV3.0.0]]
-[[Jetson TK1でOpenCV3.1.0をビルド]]
-[[Arm]]