ShellAlbert / Jetson-TX2

new platform for processing video & audio
GNU Lesser General Public License v3.0
2 stars 0 forks source link

build opencv for jetson tx2 with cuda supported. #18

Open ShellAlbert opened 4 years ago

ShellAlbert commented 4 years ago

https://www.jetsonhacks.com/2018/05/28/build-opencv-3-4-with-cuda-on-nvidia-jetson-tx2/

I remember building OpenCV on the Jetson a while back, but I don’t remember if I enabled CUDA 9 support. Is there a way to tell whether this support is built in from the command-line? You may be able to check with Python: $ python

import cv2 print(cv2.getBuildInformation())

ShellAlbert commented 4 years ago

QQ截图20190813112957

https://github.com/NVIDIA/libglvnd.git Building the library

libglvnd build-depends on libx11, glproto and libxext. On Debian and derivatives, run:

sudo apt-get install libxext-dev libx11-dev x11proto-gl-dev

Run ./autogen.sh, then run ./configure and make.

ShellAlbert commented 4 years ago

删除掉通过apt-get install安装的opencv,这种安装不支持cuda. $ sudo apt-get purge libopencv*

ShellAlbert commented 4 years ago

$ git clone https://github.com/jetsonhacks/buildOpenCVTX2.git $ cd buildOpenCVTX2 vim buildOpenCV.sh add the following line

sudo ln -sf /usr/local/lib/libGL.so.1.7.0 /usr/lib/aarch64-linux-gnu/libGL.so

before time cmake -D CMAKE_BUILD_TYPE=RELEASE \ -D CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} \ -D WITH_CUDA=ON \ -D CUDA_ARCH_BIN=${ARCH_BIN} \ -D CUDA_ARCH_PTX="" \ -D ENABLE_FAST_MATH=ON \ -D CUDA_FAST_MATH=ON \ -D WITH_CUBLAS=ON \ -D WITH_LIBV4L=ON \ -D WITH_GSTREAMER=ON \ -D WITH_GSTREAMER_0_10=OFF \ -D WITH_QT=ON \ -D WITH_OPENGL=ON \ -D BUILD_EXAMPLES=OFF \ ../ $ sudo ./buildOpenCV.sh

after finished,the libopencvXXX.so will be installed in /usr/local/lib directory.

ShellAlbert commented 4 years ago

QQ截图20190813113059 QQ截图20190813113116 这样经过自己编译的opencv库,是支持cuda加速的。