jetson nano opencv3.4.5安装,与opencv4.1.1共存

我的JETSON NANO 烧完系统后,已经存在了OPENCV4.1.1,但是现在大量的代码还在用OPENCV3,所以需要手动安装一份
记录一下安装过程中的报错及解决
opencv3.4.5以及opencv_contrib-3.4.5及ippicv分享
链接:https://pan.baidu.com/s/1-gtr7cgkZ1tlDdqw4Eu-Hg
提取码:mcz0
将opencv_contrib-3.4.5解压在opencv3.4.5目录下
依赖项参考这个
源码编译OpenCV卡在ippicv解决办法(必做)
带CUDA的OPENCV编译

cd opencv-3.4.5
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local/opencv3  -DOPENCV_EXTRA_MODULES_PATH=/home/cz/opencv-3.4.5/opencv_contrib-3.4.5/modules  -D WITH_CUDA=ON -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D ENABLE_FAST_MATH=1 -D CUDA_FAST_MATH=1 -D WITH_CUBLAS=1 -D CUDA_GENERATION=Auto -DCUDA_ARCH_BIN=5.3 -DCUDA_ARCH_PTX=5.3 ..
make -j4
sudo make install

make 报错 没有opencv2/xfeatures2d/cuda.hpp这个文件
搜索一下发现就在/opencv-3.4.5/opencv_contrib-3.4.5/modules/xfeatures2d/include/opencv2/xfeatures2d
把地址改了就行

GL头文件问题

In file included from /home/ubuntu/build/opencv/modules/core/src/opengl.cpp:50:0:
/usr/local/cuda/include/cuda_gl_interop.h:64:2: error: #error Please include the appropriate gl headers before including cuda_gl_interop.h
 #error Please include the appropriate gl headers before including cuda_gl_interop.h

解决方法
注释/usr/local/cuda/include/cuda_gl_interop.h中

#ifndef GL_VERSION
#error Please include the appropriate gl headers before including cuda_gl_interop.h
#endif
#else

使用vim修改

cd /usr/local/cuda-10.0/include
sudo vim cuda_gl_interop.h 
进入vim
i 进入编辑
注释上面四条语句
esc 退出编辑
:w 保存
:q 退出

想要使用OPENCV3而非默认的4时,需要在CMakeLists.txt中FIND_PACKAGE(OpenCV REQUIRED),前加一句set(OpenCV_DIR “/usr/local/opencv3/share/OpenCV”) ,参考这个

CMAKE_MINIMUM_REQUIRED( VERSION 2.8)
PROJECT(useOpenCV)
set(OpenCV_DIR "/usr/local/opencv3/share/OpenCV") 
FIND_PACKAGE(OpenCV REQUIRED)
INCLUDE_DIRECTORIES(${OpenCV_INCLUDE_DIRS})
add_executable(useOpenCV useOpenCV.cpp)
TARGET_LINK_LIBRARIES(useOpenCV ${OpenCV_LIBRARIES})

你可能感兴趣的:(jetson nano opencv3.4.5安装,与opencv4.1.1共存)