Compilation OpenCV sur Debian

Note : skimage est une alternative à OpenCV

Compilation et installation d'OpenCV 3.3.0 sous Debian 9

Prérequis

sudo apt-get update sudo apt-get install -y build-essential sudo apt-get install -y cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev sudo apt-get install -y python-dev python-numpy libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libdc1394-22-dev sudo apt-get -y install unzip # Pour la création du .deb sudo apt-get install -y fakeroot checkinstall

Téléchargement des sources

mkdir ~/src cd ~/src wget https://github.com/opencv/opencv/archive/3.3.0.zip unzip 3.3.0.zip

Pas nécessaire si -DWITH_IPP=OFF on option de compilation

mkdir -p ~/src/opencv-3.3.0/3rdparty/ippicv/downloads/linux-8b449a536a2157bcad08a2b9f266828b/ cd !$ export https_proxy=http://192.168.56.1:3128 wget https://sourceforge.net/projects/opencvlibrary/files/3rdparty/ippicv/ippicv_linux_20141027.tgz

Compilation

cd ~/src/opencv-3.3.0/cmake #cmake -DWITH_CUDA=OFF -DWITH_QT=OFF -DWITH_OPENGL=OFF -DFORCE_VTK=ON -DWITH_TBB=ON -DWITH_GDAL=ON -DWITH_XINE=ON -DBUILD_EXAMPLES=ON -DENABLE_PRECOMPILED_HEADERS=OFF .. #cmake -DCMAKE_INSTALL_PREFIX=/usr/lib/opencv3.0 -DWITH_FFMPEG=OFF -DWITH_IPP=OFF -DWITH_CUDA=OFF -DWITH_QT=OFF -DWITH_OPENGL=OFF -DFORCE_VTK=ON -DWITH_TBB=ON -DWITH_GDAL=ON -DWITH_XINE=ON -DBUILD_EXAMPLES=ON -DENABLE_PRECOMPILED_HEADERS=OFF .. cmake -DBUILD_TIFF=ON \ -DBUILD_opencv_java=OFF \ -DBUILD_SHARED_LIBS=ON \ -DBUILD_EXAMPLES=OFF \ -DBUILD_TESTS=OFF \ -DBUILD_PERF_TESTS=OFF \ -DWITH_CUDA=ON \ -DCUDA_TOOLKIT_ROOT_DIR=/usr/local/cuda-8.0 \ -DCUDA_ARCH_BIN='3.0 3.5 5.0 6.0 6.2' \ -DCUDA_ARCH_PTX="" \ -DCPU_DISPATCH=AVX,AVX2 \ -DENABLE_PRECOMPILED_HEADERS=OFF \ -DWITH_OPENGL=OFF \ -DWITH_OPENCL=OFF \ -DWITH_QT=OFF \ -DWITH_IPP=ON \ -DWITH_TBB=ON \ -DFORCE_VTK=ON \ -DWITH_EIGEN=ON \ -DWITH_V4L=ON \ -DWITH_XINE=ON \ -DWITH_GDAL=ON \ -DWITH_1394=OFF \ -DWITH_FFMPEG=OFF \ -DBUILD_PROTOBUF=OFF \ -DCMAKE_BUILD_TYPE=RELEASE \ -DCMAKE_INSTALL_PREFIX=/usr/lib/opencv3.3 \ .. make -j $(nproc)

Installation

sudo make install

Création d'un paquet Debian avec checkinstall

cat >description-pak <<EOF libopencv This package contains the header files and static library needed to compile applications that use OpenCV (Open Computer Vision) core. . The Open Computer Vision Library is a collection of algorithms and sample code for various computer vision problems. The library is compatible with IPL (Intel's Image Processing Library) and, if available, can use IPP (Intel's Integrated Performance Primitives) for better performance. . OpenCV provides low level portable data types and operators, and a set of high level functionalities for video acquisition, image processing and analysis, structural analysis, motion analysis and object tracking, object recognition, camera calibration and 3D reconstruction. EOF echo |fakeroot checkinstall --install=no \ --strip \ --stripso \ --addso \ --exclude '/home' \ --gzman \ --reset-uids \ --maintainer 'ACME SAS \<[mailto:root@acme.fr\>]root@acme.fr\>' \ --pkglicense 'Copyright' \ --pkgname opencv-all3.3 \ --pkgrelease 1 \ --pkgversion 3.3.0 \ --pkgsource 'https://github.com/opencv/opencv/archive/3.3.0.zip'

TODO : ldconfig

Exemple

libcudnn 7 libcudnn7

Voir http://man7.org/linux/man-pages/man5/deb-shlibs.5.html

# Triggers added by dh_makeshlibs/11.1.6ubuntu2
activate-noawait ldconfig

Voir : https://manpages.debian.org/unstable/dpkg-dev/deb-triggers.5.fr.html