本机情况
操作系统:Ubuntu16.04
本机已安装NVIDIA显卡驱动+CUDA+cuDNN,安装方法见【安装链接】
OpenCV3.3编译安装
安装准备
1.安装opencv的工具和依赖项
sudo apt-get install cmake
sudo apt-get install build-essential libgtk2.0-dev libavcodec-dev
sudo apt-get install libavformat-dev libjpeg.dev libtiff4.dev
sudo apt-get install libswscale-dev libjasper-dev
sudo apt-get install libjpeg62-dev
sudo apt-get install v4l2ucp
sudo apt-get install v4l-utils
sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler
sudo apt-get install --no-install-recommends libboost-all-dev
sudo apt-get install libopenblas-dev liblapack-dev libatlas-base-dev
sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev
(若编译中发现缺少的依赖,使用sudo apt-get install安装即可)
2.下载opencv3.3源码(Opencv官方github账号链接)
【opencv3.3源码下载链接】
如果需要使用opencv_contrib的扩展功能,请在此链接下载【Opencv_contrib3.3下载链接】
编译Opencv
1.将opencv-3.3.0源码(需要的可以加上opencv_contrib3.3)放到你选择安装Opencv的目录中(我放在/home下面的),并解压
unzip opencv-3.3.0.zip
unzip opencv_contrib-3.3.0.zip
2.进入opencv-3.3源码目录内,并创建build目录
cd opencv-3.3.0/
mkdir build
cd build
3.用cmake命令制作Makefile文件
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_CUDA=ON -D ENABLE_FAST_MATH=1 -D CUDA_FAST_MATH=1 -D WITH_CUBLAS=1 -D INSTALL_C_EXAMPLES=OFF -D INSTALL_PYTHON_EXAMPLES=ON -D OPENCV_EXTRA_MODULES_PATH=/home/despe