1.官网下载opencv3.1.0源代码;https://github.com/opencv/opencv/archive/3.1.0.zip
2.修改cmake文件夹中的FindCUDA.cmake文件;
(1)查找“unset(CUDA_nppi_LIBRARY CACHE)”;
替换为:
unset(CUDA_nppial_LIBRARY CACHE)
unset(CUDA_nppicc_LIBRARY CACHE)
unset(CUDA_nppicom_LIBRARY CACHE)
unset(CUDA_nppidei_LIBRARY CACHE)
unset(CUDA_nppif_LIBRARY CACHE)
unset(CUDA_nppig_LIBRARY CACHE)
unset(CUDA_nppim_LIBRARY CACHE)
unset(CUDA_nppist_LIBRARY CACHE)
unset(CUDA_nppisu_LIBRARY CACHE)
unset(CUDA_nppitc_LIBRARY CACHE)
(2)查找"find_cuda_helper_libs(nppi)";
替换为:
find_cuda_helper_libs(nppial)
find_cuda_helper_libs(nppicc)
find_cuda_helper_libs(nppicom)
find_cuda_helper_libs(nppidei)
find_cuda_helper_libs(nppif)
find_cuda_helper_libs(nppig)
find_cuda_helper_libs(nppim)
find_cuda_helper_libs(nppist)
find_cuda_helper_libs(nppisu)
find_cuda_helper_libs(nppitc)
3.安装cmake工具;
sudo apt-get install cmake
4.安装依赖库;
sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev libavformat-dev libjpeg.dev libtiff4.dev libswscale-dev libjasper-dev qtbase5-dev
5.将头文件cuda_fp16.h添加至 opencv\modules\cudev\include\opencv2\cudev\common.hpp;
即在common.hpp中添加:
#include <cuda_fp16.h>
6.修改opencv3.1.0/modules/cudalegacy/src/graphcuts.cpp文件;
#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER)
修改为:
#if !defined (HAVE_CUDA) || defined (CUDA_DISABLER) || (CUDART_VERSION>=8000)
7.解压下载的opencv3.1.0源码,进入到opencv3.1.0文件夹,创建release文件夹并进入;
mkdir release && cd release
8.cmake配置编译 ;
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D CUDA_GENERATION=Kepler -D BUILD_PNG=ON ..
9.make编译和安装;
make -j$(nproc)
sudo make install
10.安装完成!