Installer openCV 2.4.12 pour ubuntu et Qt5
Bonjour à tous,
après avoir pas mal galérer à installer openCV 2.4.12 sur ubuntu et le faire fonctionner avec ubuntu, j’ai décidé de partager mon retour d’expérience.
Installer les dépendances :
1 2 3 4 5 6 7 8 9 10 11 |
# install dependencies sudo apt-get update sudo apt-get install -y build-essential g++ sudo apt-get install -y cmake git sudo apt-get install -y libgtk2.0-dev sudo apt-get install -y pkg-config sudo apt-get install -y python-numpy python-dev sudo apt-get install -y libavcodec-dev libavformat-dev libswscale-dev sudo apt-get install -y libjpeg-dev libpng-dev libtiff-dev libjasper-dev sudo apt-get -qq install libopencv-dev build-essential checkinstall cmake pkg-config yasm libjpeg-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libdc1394-22-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev python-dev python-numpy libtbb-dev libqt4-dev libgtk2.0-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils |
Ensuite récupérer openCV depuis git
1 2 3 |
mkdir -p ~/dev/ cd ~/dev git clone https://github.com/Itseez/opencv.git |
Maintenant compilons le tout
1 2 3 4 5 6 7 8 |
cd opencv-2.4.12 mkdir release cd release # compile and install cmake -G "Unix Makefiles" -D CMAKE_CXX_COMPILER=/usr/bin/g++ CMAKE_C_COMPILER=/usr/bin/gcc -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 INSTALL_C_EXAMPLES=ON -D INSTALL_PYTHON_EXAMPLES=ON -D BUILD_EXAMPLES=ON -D WITH_QT=ON -D WITH_OPENGL=ON -D BUILD_FAT_JAVA_LIB=ON -D INSTALL_TO_MANGLED_PATHS=ON -D INSTALL_CREATE_DISTRIB=ON -D INSTALL_TESTS=ON -D ENABLE_FAST_MATH=ON -D WITH_IMAGEIO=ON -D BUILD_SHARED_LIBS=OFF -D WITH_GSTREAMER=ON .. make all -j4 # 4 cores sudo make install |
dans le dossier /etc/ld.so.conf.d/
créer un fichier « opencv.conf »
Et coller ceci dedans :
/usr/local/lib
Maintenant executer la commande
sudo ldconfig
Maintenant ajoutons les dépendances dans notre projet QT (dans le fichier .pro )
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
INCLUDEPATH += . INCLUDEPATH += /usr/local/include INCLUDEPATH += /usr/local/include/opencv INCLUDEPATH += /usr/local/include/opencv2 INCLUDEPATH += /usr/local/include/opencv2/core INCLUDEPATH += /usr/local/include/opencv2/highgui INCLUDEPATH += /usr/local/include/opencv2/imgproc INCLUDEPATH += /usr/local/include/opencv2/flann INCLUDEPATH += /usr/local/include/opencv2/photo INCLUDEPATH += /usr/local/include/opencv2/video INCLUDEPATH += /usr/local/include/opencv2/features2d INCLUDEPATH += /usr/local/include/opencv2/objdetect INCLUDEPATH += /usr/local/include/opencv2/calib3d INCLUDEPATH += /usr/local/include/opencv2/ml INCLUDEPATH += /usr/local/include/opencv2/contrib LIBS += `pkg-config opencv --cflags --libs` |