实际中测试使用opencv 3.2.0 2.4.11版本
1、官方教程
https://docs.opencv.org/master/d7/d9f/tutorial_linux_install.html
2、问题总结
(1) E: 无法定位软件包 libjasper-dev
解决办法:https://blog.csdn.net/weixin_41053564/article/details/81254410,添加源再安装
(2) CMake Error at 3rdparty/ippicv/downloader.cmake:73
修改编译命令,添加选项,关闭IPP
原命令:cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local ..
改为:cmake -D CMAKE_BUILD_TYPE=Release -D WITH_IPP=OFF -D CMAKE_INSTALL_PREFIX=/usr/local ..
(3) /usr/include/c++/7/cstdlib:75:15: fatal error: stdlib.h: 没有那个文件或目录#include_next <stdlib.h>
解决方法:参考https://blog.csdn.net/renweiyi1487/article/details/104160879/
(4) CMake Error: CUDA_nppi_LIBRARY (ADVANCED)
通过查看cuda版本为9.0
解决办法:参考https://blog.csdn.net/Mundane_World/article/details/79786272
(5) error: the compiler can assume that the address of ‘annotate_img’ will never be NULL [-Werror=address]
解决办法:https://blog.csdn.net/m0_38024766/article/details/78715016
(6) cuda问题参考
https://github.com/opencv/opencv/issues/6500
3 安装过程
(1)下载opencv源码
(2)编译安装
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=Release -D WITH_IPP=OFF -D CMAKE_INSTALL_PREFIX=/usr/local -DBUILD_opencv_legacy=OFF -DCUDA_ARCH_BIN:STRING="5.0" -DCUDA_ARCH_PTX:STRING="5.0" -DWITH_CUDA=ON ..
make -j4
sudo make install
(3)查看opencv版本
pkg-config --modversion opencv