Jetson TX1 install Opencv3

https://jkjung-avt.github.io/opencv3-on-tx2/

注意:在编译的时候会遇到内存空间不足的情况,可以插入U盘,将程序拷贝到U盘内编译,然后安装到Jetson上。U盘格式化采用NTFS,其他格式可能无法识别。

Installation Steps

I’d start by cleaning up older opencv packages and installing necessary dependencies for building opencv.

Regarding the python matplotlibrc modifications below, refer to this StackOverflow thread for more details.

1### Remove all old opencv stuffs installed by JetPack (or OpenCV4Tegra) 2$ sudo apt-get purge libopencv* 3### I prefer using newer version of numpy (installed with pip), so ### I'd remove this python-numpy apt package as well $ sudo apt-get purge python-numpy ### Remove other unused apt packages $ sudo apt autoremove ### Upgrade all installed apt packages to the latest versions (optional) $ sudo apt-get update $ sudo apt-get dist-upgrade ### Update gcc apt package to the latest version (highly recommended) $ sudo apt-get install --only-upgrade g++-5 cpp-5 gcc-5 ### Install dependencies based on the Jetson Installing OpenCV Guide $ sudo apt-get install build-essential make cmake cmake-curses-gui \ g++ libavformat-dev libavutil-dev \ libswscale-dev libv4l-dev libeigen3-dev \ libglew-dev libgtk2.0-dev ### Install dependencies for gstreamer stuffs $ sudo apt-get install libdc1394-22-dev libxine2-dev \ libgstreamer1.0-dev \ libgstreamer-plugins-base1.0-dev ### Install additional dependencies according to the pyimageresearch ### article $ sudo apt-get install libjpeg8-dev libjpeg-turbo8-dev libtiff5-dev \ libjasper-dev libpng12-dev libavcodec-dev $ sudo apt-get install libxvidcore-dev libx264-dev libgtk-3-dev \ libatlas-base-dev gfortran $ sudo apt-get install libopenblas-dev liblapack-dev liblapacke-dev ### Install Qt5 dependencies $ sudo apt-get install qt5-default ### Install dependencies for python3 $ sudo apt-get install python3-dev python3-pip python3-tk $ sudo pip3 install numpy $ sudo pip3 install matplotlib ### Modify matplotlibrc (line #41) as 'backend : TkAgg' $ sudo vim /usr/local/lib/python3.5/dist-packages/matplotlib/mpl-data/matplotlibrc ### Also install dependencies for python2 ### Note that I install numpy with pip, so that I'd be using a newer ### version of numpy than the apt-get package $ sudo apt-get install python-dev python-pip python-tk $ sudo pip2 install numpy $ sudo pip2 install matplotlib ### Modify matplotlibrc (line #41) as 'backend : TkAgg' $ sudo vim /usr/local/lib/python2.7/dist-packages/matplotlib/mpl-data/matplotlibrc

Before downloading and building opencv-3.4.0, I’d first do some modifications according to this post, in order to fix OpenGL related compilation problems . More specifically, I’d modify /usr/local/cuda/include/cuda_gl_interop.h and fix the symbolic link of libGL.so.

1$ sudo vim /usr/local/cuda/include/cuda_gl_interop.h 2$ cd /usr/lib/aarch64-linux-gnu/ 3$ sudo ln -sf tegra/libGL.so libGL.so

Here’s how the relevant lines (line #62~68) of cuda_gl_interop.h look like after the modification.

1//#if defined(__arm__) || defined(__aarch64__) 2//#ifndef GL_VERSION 3//#error Please include the appropriate gl headers before including cuda_gl_interop.h 4//#endif 5//#else 6 #include <GL/gl.h> 7//#endif

Next, download opencv-3.4.0 source code, cmake and compile. Note that opencv_contrib modules (cnn/dnn stuffs) would cause problem on pycaffe, so after some experiments I decided not to include those modules at all.

1### Download opencv-3.4.0 source code 2$ mkdir -p ~/src 3$ cd ~/src $ wget https://github.com/opencv/opencv/archive/3.4.0.zip \ -O opencv-3.4.0.zip $ unzip opencv-3.4.0.zip ### Build opencv (CUDA_ARCH_BIN="6.2" for TX2, or "5.3" for TX1) $ cd ~/src/opencv-3.4.0 $ mkdir build $ cd build $ cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local \ -D WITH_CUDA=ON -D CUDA_ARCH_BIN="6.2" -D CUDA_ARCH_PTX="" \ -D WITH_CUBLAS=ON -D ENABLE_FAST_MATH=ON -D CUDA_FAST_MATH=ON \ -D ENABLE_NEON=ON -D WITH_LIBV4L=ON -D BUILD_TESTS=OFF \ -D BUILD_PERF_TESTS=OFF -D BUILD_EXAMPLES=OFF \ -D WITH_QT=ON -D WITH_OPENGL=ON .. $ make -j4 $ sudo make install

Just for reference, here’s the resulting opencv-3.4.0 cmake configuration for my Jetson TX2 system.

1-- General configuration for OpenCV 3.4.0 ===================================== 2-- Version control: unknown 3-- 4-- Platform: 5-- Timestamp: 2018-01-29T07:58:45Z 6-- Host: Linux 4.4.38-tegra aarch64 7-- CMake: 3.5.1 8-- CMake generator: Unix Makefiles 9-- CMake build tool: /usr/bin/make 10-- Configuration: RELEASE 11-- 12-- CPU/HW features: 13-- Baseline: NEON FP16 14-- required: NEON 15-- disabled: VFPV3 16-- 17-- C/C++: 18-- Built as dynamic libs?: YES 19-- C++ Compiler: /usr/bin/c++ (ver 5.4.0) 20-- 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 -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG 21-- 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 -Wuninitialized -Winit-self -Wno-narrowing -Wno-delete-non-virtual-dtor -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -g -O0 -DDEBUG -D_DEBUG 22-- C Compiler: /usr/bin/cc 23-- 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 -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -O3 -DNDEBUG -DNDEBUG 24-- 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 -Wuninitialized -Winit-self -Wno-narrowing -Wno-comment -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -g -O0 -DDEBUG -D_DEBUG 25-- Linker flags (Release): 26-- Linker flags (Debug): 27-- ccache: NO 28-- Precompiled headers: YES 29-- Extra dependencies: dl m pthread rt /usr/lib/aarch64-linux-gnu/libGLU.so /usr/lib/aarch64-linux-gnu/libGL.so cudart nppc nppial nppicc nppicom nppidei nppif nppig nppim nppist nppisu nppitc npps cublas cufft -L/usr/local/cuda-8.0/lib64 30-- 3rdparty dependencies: 31-- 32-- OpenCV modules: 33-- To be built: calib3d core cudaarithm cudabgsegm cudacodec cudafeatures2d cudafilters cudaimgproc cudalegacy cudaobjdetect cudaoptflow cudastereo cudawarping cudev dnn features2d flann highgui imgcodecs imgproc ml objdetect photo python2 python3 python_bindings_generator shape stitching superres video videoio videostab 34-- Disabled: js world 35-- Disabled by dependency: - 36-- Unavailable: java ts viz 37-- Applications: apps 38-- Documentation: NO 39-- Non-free algorithms: NO 40-- 41-- GUI: 42-- QT: YES (ver 5.5.1) 43-- QT OpenGL support: YES (Qt5::OpenGL 5.5.1) 44-- GTK+: NO 45-- OpenGL support: YES (/usr/lib/aarch64-linux-gnu/libGLU.so /usr/lib/aarch64-linux-gnu/libGL.so) 46-- VTK support: NO 47-- 48-- Media I/O: 49-- ZLib: /usr/lib/aarch64-linux-gnu/libz.so (ver 1.2.8) 50-- JPEG: /usr/lib/aarch64-linux-gnu/libjpeg.so (ver ) 51-- WEBP: build (ver encoder: 0x020e) 52-- PNG: /usr/lib/aarch64-linux-gnu/libpng.so (ver 1.2.54) 53-- TIFF: /usr/lib/aarch64-linux-gnu/libtiff.so (ver 42 / 4.0.6) 54-- JPEG 2000: /usr/lib/aarch64-linux-gnu/libjasper.so (ver 1.900.1) 55-- OpenEXR: build (ver 1.7.1) 56-- 57-- Video I/O: 58-- DC1394: YES (ver 2.2.4) 59-- FFMPEG: YES 60-- avcodec: YES (ver 56.60.100) 61-- avformat: YES (ver 56.40.101) 62-- avutil: YES (ver 54.31.100) 63-- swscale: YES (ver 3.1.101) 64-- avresample: NO 65-- GStreamer: 66-- base: YES (ver 1.8.3) 67-- video: YES (ver 1.8.3) 68-- app: YES (ver 1.8.3) 69-- riff: YES (ver 1.8.3) 70-- pbutils: YES (ver 1.8.3) 71-- libv4l/libv4l2: 1.10.0 / 1.10.0 72-- v4l/v4l2: linux/videodev2.h 73-- gPhoto2: NO 74-- 75-- Parallel framework: pthreads 76-- 77-- Trace: YES (built-in) 78-- 79-- Other third-party libraries: 80-- Lapack: NO 81-- Eigen: YES (ver 3.2.92) 82-- Custom HAL: YES (carotene (ver 0.0.1)) 83-- 84-- NVIDIA CUDA: YES (ver 8.0, CUFFT CUBLAS FAST_MATH) 85-- NVIDIA GPU arch: 62 86-- NVIDIA PTX archs: 87-- 88-- OpenCL: YES (no extra features) 89-- Include path: /home/nvidia/src/opencv-3.4.0/3rdparty/include/opencl/1.2 90-- Link libraries: Dynamic load 91-- 92-- Python 2: 93-- Interpreter: /usr/bin/python2.7 (ver 2.7.12) 94-- Libraries: /usr/lib/aarch64-linux-gnu/libpython2.7.so (ver 2.7.12) 95-- numpy: /usr/local/lib/python2.7/dist-packages/numpy/core/include (ver 1.14.0) 96-- packages path: lib/python2.7/dist-packages 97-- 98-- Python 3: 99-- Interpreter: /usr/bin/python3 (ver 3.5.2) 100-- Libraries: /usr/lib/aarch64-linux-gnu/libpython3.5m.so (ver 3.5.2) 101-- numpy: /usr/local/lib/python3.5/dist-packages/numpy/core/include (ver 1.14.0) 102-- packages path: lib/python3.5/dist-packages 103-- 104-- Python (for build): /usr/bin/python2.7 105-- 106-- Java: 107-- ant: NO 108-- JNI: NO 109-- Java wrappers: NO 110-- Java tests: NO 111-- 112-- Matlab: NO 113-- 114-- Install to: /usr/local 115-- ----------------------------------------------------------------- 116-- 117-- Configuring done 118-- Generating done 119-- Build files have been written to: /home/nvidia/src/opencv-3.4.0/build

To verify the installation:

1$ ls /usr/local/lib/python3.5/dist-packages/cv2.* 2/usr/local/lib/python3.5/dist-packages/cv2.cpython-35m-aarch64-linux-gnu.so 3$ ls /usr/local/lib/python2.7/dist-packages/cv2.* /use/local/lib/python2.7/dist-packages/cv2.so $ python3 -c 'import cv2; print(cv2.__version__)' 3.4.0 $ python2 -c 'import cv2; print(cv2.__version__)' 3.4.0

Bonus:

点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

皕杰报表之UUID

​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

swap空间的增减方法

(1)增大swap空间去激活swap交换区:swapoff v /dev/vg00/lvswap扩展交换lv:lvextend L 10G /dev/vg00/lvswap重新生成swap交换区:mkswap /dev/vg00/lvswap激活新生成的交换区:swapon v /dev/vg00/lvswap

Jetson TX1 install Opencv3 - HelloWorld