ubuntu16.04基于cuda9.0编译安装opencv2.4.13.6的全过程

Ubuntu16.04,ffmpeg2.4.14(切记不要用高版本3.*),opencv2.4.13.6,xvidcore1.3.5

安装基本环境
sudo apt-get update

sudo apt-get install build-essential
sudo apt-get install cmake git libgtk2.0-dev pkg-config
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev
sudo apt-get install python-dev python-numpy libtbb2 libtbb-dev
sudo apt-get install libjpeg-dev libpng-dev libtiff-dev libjasper-dev libdc1394-22-dev libx264-dev
sudo apt-get install libfaac-dev libmp3lame-dev libtheora-dev libvorbis-dev libxvidcore-dev libopencore-amrnb-dev libopencore-amrwb-dev libswscale-dev libv4l-dev
sudo apt-get install yasm

到官网https://labs.xvid.com/source/下载xvidcore1.3.5
然后加压进入 cd /home/zhex/Downloads/xvidcore-1.3.2/build/generic
执行
./configure --prefix=/usr
make
make install
解压ffmpeg-2.4.14
cd /home/zhex/Downloas/ffmpeg-2.4.14
执行
./configure --prefix=/usr/local/ffmpeg/ --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-libxvid --enable-nonfree --enable-postproc --enable-version3 --enable-x11grab

make
make install

修改/etc/profile文件,在末尾加上
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/ffmpeg/lib/"

保存后执行
source /etc/profile

在/etc/ld.so.conf.d目录下新建ffmepg.conf文件,写入/usr/local/ffmpeg保存后执行
ldconfig

到官网下载https://opencv.org/releases/ opencv2.4.13.6
解压进入目录中:
mkdir build
cd build
cmake -D CMAKE_BUILD_TYPE=Release -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_TIFF=ON -D BUILD_EXAMPLES=ON -D BUILD_NEW_PYTHON_SUPPORT=ON -D CMAKE_LIBRARY_PATH=/usr/local/cuda/lib64/stubs -D CUDA_CUDA_LIBRARY=/usr/local/cuda/lib64/stubs/libcuda.so --WITHFFMPEG …
末尾点号不能省略 斜体加粗是体现出基于cuda的编译

make
make install

至此所有的环境都已完成,如果出现了opencv版本使用冲突,就/etc/ld.so.conf.d目录下新建libopencv.conf文件,写入
/usr/local/lib
执行 ldconfig。在完成编译后记得在python里面查看一下版本

你可能感兴趣的:(CV)