Drive PX2 build opencv

#Drive PX2 (cuda9.0)编译安装OpenCV3.1

首先按照官方CUDA8.0+OpenCV3.2版本教程进行安装OpenCV Building Tegra with cuda

另附上中文翻译–编译opencv

# Clone the opencv repository locally:
$ git clone https://github.com/opencv/opencv.git
# In the same base directory from which you cloned OpenCV:
$ git clone https://github.com/opencv/opencv_extra.git

$ cd opencv_extra
$ git checkout -b v3.1.0 3.1.0

$ cd ../opencv
$ git checkout -b v3.1.0 3.1.0
# While still in the opencv directory:
$ git cherry-pick 108961.0
$ git cherry pick cdb9c
$ git cherry-pick 24dbb

$ sudo apt-add-repository universe
$ sudo apt-get update

$ sudo apt-get install \
    libglew-dev \
    libtiff5-dev \
    zlib1g-dev \
    libjpeg-dev \
    libpng12-dev \
    libjasper-dev \
    libavcodec-dev \
    libavformat-dev \
    libavutil-dev \
    libpostproc-dev \
    libswscale-dev \
    libeigen3-dev \
    libtbb-dev \
    libgtk2.0-dev \
    pkg-config

$ sudo apt-get install python-dev python-numpy python-py python-pytest
# And, optionally:
$ sudo apt-get install python3-dev python3-numpy python3-py python3-pytest

$ cd ..
$ mkdir build
$ cd build

$ cmake \
	-DCMAKE_BUILD_TYPE=Release \
	-DCMAKE_INSTALL_PREFIX=/usr \
	-DBUILD_PNG=OFF \
	-DBUILD_TIFF=OFF \
	-DBUILD_TBB=OFF \
	-DBUILD_JPEG=OFF \
	-DBUILD_JASPER=OFF \
	-DBUILD_ZLIB=OFF \
	-DBUILD_EXAMPLES=ON \
	-DBUILD_opencv_java=OFF \
	-DBUILD_opencv_python2=ON \
	-DBUILD_opencv_python3=OFF \
	-DENABLE_NEON=ON \
	-DWITH_OPENCL=OFF \
	-DWITH_OPENMP=OFF \
	-DWITH_FFMPEG=ON \
	-DWITH_GSTREAMER=OFF \
	-DWITH_GSTREAMER_0_10=OFF \
	-DWITH_CUDA=ON \
	-DWITH_GTK=ON \
	-DWITH_VTK=OFF \
	-DWITH_TBB=ON \
	-DWITH_1394=OFF \
	-DWITH_OPENEXR=OFF \
	-DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-9.0 \
	-DCUDA_ARCH_BIN='6.1 6.2' \
	-DCUDA_ARCH_PTX="" \
	-DINSTALL_C_EXAMPLES=ON \
	-DINSTALL_TESTS=ON \
	-DOPENCV_TEST_DATA_PATH=../opencv_extra/testdata \
	-DCMAKE_C_COMPILER=/usr/bin/gcc-4.9 -DCMAKE_CXX_COMPILER=/usr/bin/g++-4.9 \
../opencv \
&& make -j4 \
&& make test ARGS="--verbose --parallel 2" \
# && sudo make install

按照这个教程运行完毕后一般会报错,

CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
Please set them or make sure they are set and tested correctly in the CMake files:
CUDA_nppi_LIBRARY (ADVANCED)
...

这是因为cuda版本的问题,解决方法如下链接https://stackoverflow.com/questions/46584000/cmake-error-variables-are-set-to-notfound
就是要用十个nppi的子库替换掉nppi这个库。
然后再cmake就能成功了。
##make 错误解决
cmake成功后直接make又会爆出另外一个错误,
‘’’
/home/usrname/opencv-3.0.0/modules/cudalegacy/src/graphcuts.cpp:120:54: error: ‘NppiGraphcutState’ has not been declared
typedef NppStatus (init_func_t)(NppiSize oSize, NppiGraphcutState* ppStat
‘’’
这个错误比较好解决,见链接:https://blog.csdn.net/allyli0022/article/details/62859290
修改graphcuts.cpp这个文件就可以了,然后make,完美。

你可能感兴趣的:(code)