Jetson nano opencv3.4.5 installation, coexist with opencv4.1.1

After my JETSON NANO burned the system, OPENCV4.1.1 already exists, but now a lot of code is still using OPENCV3, so I need to manually install a
record of the errors and solutions during the installation process
Opencv3.4.5 and opencv_contrib-3.4.5 Share with ippicv
Link: https://pan.baidu.com/s/1-gtr7cgkZ1tlDdqw4Eu-Hg
extraction code: mcz0
decompress opencv_contrib-3.4.5 in the opencv3.4.5 directory
Dependency reference this
source code compilation OpenCV card is solved in ippicv Method (must do)
OPENCV compilation with CUDA

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 reports that there is no opencv2 / xfeatures2d / cuda.hpp file.
Search and find it in /opencv-3.4.5/opencv_contrib-3.4.5/modules/xfeatures2d/include/opencv2/xfeatures2d. Change
the address.

GL header file problem

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

Solution
Comment /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

Use vim to modify

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

If you want to use OPENCV3 instead of the default 4, you need to add FIND_PACKAGE (OpenCV REQUIRED) in CMakeLists.txt, add a sentence before set (OpenCV_DIR "/ usr / local / opencv3 / share / OpenCV"), refer to this

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})
Released eight original articles · won praise 11 · views 2924

Guess you like

Origin blog.csdn.net/weixin_44457020/article/details/104771003