基于Jetson TX1的opencv3.2版本的安装和摄像头调用例程

Data: 2017.04.25

Author: cjh

Theme: Install Opencv3.2 in Jetson TX1

 

由于Jetson TX1刷机后自带Opencv2.4,由于版本过低,以至于无法通过opencv调板载上的摄像头,同时在实际操作过程中发现自带摄像头API比较占CPU的资源,所以决定在不卸载Opencv2.4的基础上安装Opencv3.2,并用Opencv3.2调摄像头。

由于本人要在Jetson TX1上使用faster-rcnn,在刷机过程中尝试不安装Opencv2.4导致在识别过程中无法识别,目前还没找到原因,所以你也可以尝试同时安装两个版本。

 

首先先安装Opencv.3.2的依赖库

 

Baserequirements

sudo apt-get install build-essential

sudo apt-get install cmake git libgtk2.0-dev pkg-configlibavcodec-dev libavformat-dev libswscale-dev

 

GStreamersupport (recommended)

sudo apt-get install libgstreamer1.0-devlibgstreamer-plugins-base1.0-dev

 

Python support

sudo apt-get install python2.7-dev

sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev

 

OpenGL support

sudo apt-get install libgtkglext1 libgtkglext1-dev

sudo apt-get install qtbase5-dev

 

video4linux2support (better handling of usb cameras modes)

sudo apt-get install libv4l-dev v4l-utils qv4l2v4l2ucp

 

下载安装包

git clonehttps://github.com/opencv/opencv.git

 

也可以通过官网下载

curl -L https://github.com/opencv/opencv/archive/3.2.0.zip -o opencv-3.2.0.zip

unzip opencv-3.2.0.zip

cd opencv-3.2.0

 

编译

这是一个有用的cmake参数的列表,为您的OpenCV编译添加一些额外的功能,以使您的TX1工作。

required

  • CMAKE_BUILD_TYPE=RELEASE compiles the release version of OpenCV
  • CMAKE_INSTALL_PREFIX=/usr/local path where OpenCV will be installed
  • WITH_CUDA=ON
  • CUDA_ARCH_BIN="5.3" check latest version in CUDA GPUs reference
  • CUDA_ARCH_PTX=""

optional

  • WITH_OPENGL=ON OpenGL compatibility, requires GTK+ OpenGL Extensions the QT backend. When this guide was write, compilation faild for the combination CUDA 8.0 + OpenGL support.
  • WITH_LIBV4L=ON will use video4linux2 libraries
  • CUDA_FAST_MATH=ON Mathematical operations will run faster but less precise. See intrinsic mathematical functions
  • ENABLE_PRECOMPILED_HEADERS=OFF your TX1 does not have enough disk space for pre-compiling everything but you can trade space required by compilation time with this flag. Other options is to cross compile from a desktop pc or to download & compile from an external device, an USB 3.0 external drive will do the work and is fast enough.
  • ENABLE_NEON=ON ref
  • BUILD_TESTS=OFF disable tests
  • BUILD_PERF_TESTS=OFF disable performance tests
  • BUILD_EXAMPLES=OFF disable examples

 

根据你的需求来修改下面的配置

mkdir release

cd release

cmake -D WITH_CUDA=ON -D CUDA_ARCH_BIN="5.3" -D CUDA_ARCH_PTX="" -D WITH_OPENGL=ON -DWITH_LIBV4L=ON -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local ..

 

修改上面安装的路径,否则会和Opencv2.4冲突,建议在当前目录下将、/usr/local/ 修改为./opencvlib

 

make -j4 # ... because you want touse all your fancy TX1 cores isn't it? ;)

sudo make install

 

具体操作课参考http://dev.t7.ai/jetson/opencv/

你可能感兴趣的:(Jetson,TX1)