Skip to content

Instantly share code, notes, and snippets.

@okanon
Last active March 11, 2024 10:19
Show Gist options
  • Save okanon/c09669f3ff3351c864742bc2754b01ea to your computer and use it in GitHub Desktop.
Save okanon/c09669f3ff3351c864742bc2754b01ea to your computer and use it in GitHub Desktop.
OpenCV 3.4.1 Install Ubuntu17.10

Installation OpenCV 3.4.1 on Ubuntu 17.10

Install

Before Installation

sudo apt install -y \
		x264 \
		fcitx-libs-dev fcitx-libs-qt5 \
		mesa-utils \
		libgtk2.0-dev \
		libxvidcore-dev \
		yasm \
		libxine2-dev \
		libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev \
		libv4l-dev \
		libfaac-dev \
		libmp3lame-dev \
		libopencore-amrnb-dev \
		libtheora-dev \
		libvorbis-dev \
		ffmpeg \
		libpng-dev \
		libdc1394-22-dev \
		qt5-default \
		libtiff5-dev \
		libeigen3-dev libeigen3-doc \
		tesseract-ocr \
		tesseract-ocr-jpn \
		vtk6 \
		tcl-vtk6 \
		python-vtk6 \
		libgflags-dev \
		libleptonica-dev \
		libtesseract-dev \
		gphoto2 \
		liblapacke-dev \
		libgoogle-glog-dev \
		libprotobuf-dev \
		libprotoc-dev \
		protobuf-compiler \
		ccache \
		libgphoto2-dev \
		libavresample-dev \
		libvtk6-dev \
		libvtk6-qt-dev \
		libatlas-base-dev \
		gfortran

Download opencv & opencv_contrib from GitHub

wget https://github.com/opencv/opencv/archive/3.4.1.tar.gz
tar -xzvf 3.4.1.tar.gz
cd opencv-3.4.1
wget https://github.com/opencv/opencv_contrib/archive/3.4.1.tar.gz
tar -xzvf 3.4.1.tar.gz
mkdir build

All OpenCV packages are now downloaded.

├── opencv-3.4.1
│   ├── 3rdparty
│   ├── CMakeLists.txt
│   ├── CONTRIBUTING.md
│   ├── LICENSE
│   ├── README.md
│   ├── apps
│   ├── build
│   ├── cmake
│   ├── data
│   ├── doc
│   ├── include
│   ├── modules
│   ├── opencv_contrib-3.4.1
│   ├── platforms
│   └── samples

For build using cmake, please install with apt-get beforehand or build from source code.

Here's the problem 😓
There are a lot of build options in opencv.
This time, build all the libraries except CUDA.

Build option

OPTION FLAGS DESCRIPTION
WITH_1394 ON IEEE1394 camera device support
WITH_AVFOUNDATION OFF iOS camera framework support
WITH_CARBON OFF Use Windows Carbon
WITH_CAROTENE OFF ARM NVIDIA
WITH_CPUFEATURES OFF some cpu func support
WITH_VTK ON 3D computer graphics
WITH_CUDA OFF Cuda support
WITH_CUFFT OFF NVIDIA fast GPU support
WITH_CUBLAS OFF NVIDIA GPU-accelerated
WITH_NVCUVID OFF CUDA NVCUVID library
WITH_EIGEN ON Vector & Matrix for C++
WITH_VFW OFF Windows HighGui support
WITH_FFMPEG ON FFmpeg library support 😢
WITH_GSTREAMER ON Gstreamer support
WITH_GTK ON Use gtk+ libraries 😐
WITH_GTK_2_X OFF Use gtk+ 2.x libraries 😐
WITH_GTHREAD ON Use gthread in addition to gtk+
WITH_IPP ON Intel Performance Primitives support
WITH_HALIDE ON HALIDE Lang support
WITH_INF_ENGINE ON Inf engine support
WITH_JASPER ON libjasper support 😆
WITH_JPEG ON libjpeg support 😆
WITH_WEBP ON libwebp support 😆
WITH_OPENEXR ON HDRI magic support
WITH_OPENGL ON Open Graphics Library support
WITH_OPENVX ON Standardization libraries
WITH_OPENNI OFF OSX support access Xtion, Kinect
WITH_OPENNI2 OFF OSX support access Xtion, Kinect
WITH_PNG ON libpng support 😆
WITH_GDCM ON C++ GNU DiCoM support
WITH_PVAPI ON Allied Vision camera API
WITH_GIGEAPI ON GigE API support
WITH_ARAVIS ON Aravis support
WITH_QT OFF Qt support 😐
WITH_WIN32UI OFF Windows32 UI support
WITH_QUICKTIME OFF Use QuickTime libraries
WITH_QTKIT OFF QtKit
WITH_TBB ON Intel TBB support
WITH_OPENMP ON C++ shared memory multiprocessing
WITH_CSTRIPES ON CSTRIPES support
WITH_PTHREADS_PF ON C++ pthread support
WITH_TIFF ON libtiff support 😆
WITH_UNICAP ON Uniform Capitalization support
WITH_V4L ON Use video4linux
WITH_LIBV4L ON libv4l support 😆
WITH_DSHOW ON Use DirectShow
WITH_MSMF OFF Use Microsoft Media Foundation
WITH_XIMEA ON Alia camera
WITH_XINE ON Linux multimedia player support
WITH_CLP ON clip support
WITH_OPENCL ON OpenCL support
WITH_OPENCL_SVM ON OpenCL SVM support
WITH_OPENCLAMDFFT OFF OpenCL AMD fft support
WITH_OPENCLAMDBLAS OFF OpenCL AMD blas support
WITH_DIRECTX OFF Windows DirectX support
WITH_INTELPERC OFF Windows Intel PerC
WITH_MATLAB ON matlib support
WITH_VA ON VA support
WITH_VA_INTEL ON Intel VA support
WITH_MFX ON MFX support
WITH_GDAL ON gdal support
WITH_GPHOTO2 ON gphoto2 support
WITH_LAPACK ON Latpack support
WITH_ITT ON ITT support
BUILD_opencv_apps ON Build apps Library
BUILD_opencv_world OFF opencv all libraries 😐
BUILD_opencv_calib3d ON Build calib3d Library
BUILD_opencv_core ON Build core library
BUILD_opencv_cudaarathm OFF Build cudaarathm Library
BUILD_opencv_cudabgsegm OFF Build cudabgsegm Library
BUILD_opencv_cudacodec OFF Build cudacodec Library
BUILD_opencv_cudafeatures2d OFF Build cudafeatures2d Library
BUILD_opencv_cuclafilters OFF Build cuclafilters Library
BUILD_opencv_cuciaimgproc OFF Build cuciaimgproc Library
BUILD_opencv_cudalegacy OFF Build cudalegacy Library
BUILD_opencv_cudaobjdetect OFF Build cudaobjdetect Library
BUILD_opencv_cudaoptflow OFF Build cudaoptflow Library
BUILD_opencv_cudastereo OFF Build cudastereo Library
BUILD_opencv_cudawarping OFF Build cudawarping Library
BUILD_opencv_cudev OFF Build cudev Library
BUILD_opencv_features2d ON Build features2d Library
BUILD_opencv_flann ON Build flann Library
BUILD_opencv_hal ON Build hal Library
BUILD_opencv_highgui ON Build highgui Library
BUILD_opencv_imgcodecs ON Build imgcodecs Library
BUILD_opencv_imgproc ON Build imgproc Library
BUILD_opencv_ml ON Build ml Library
BUILD_opencv_objdetect ON Build objdetect Library
BUILD_opencv_photo ON Build photo Library
BUILD_opencv_sharp ON Build sharp Library
BUILD_opencv_dnn ON Build dnn Library
BUILD_opencv_js OFF javascript support 😡
BUILD_opencv_aruco ON ArUco and ChArUco Markers
BUILD_opencv_bgsegm ON Background segmentation algorithm
BUILD_opencv_bioinspired ON Biological Vision
BUILD_opencv_ccalib ON Custom Calibration
BUILD_opencv_cnn_3dobj ON Deep Object Recognition and Pose
BUILD_opencv_cvv ON Computer Vision Debugger
BUILD_opencv_datasets ON Datasets Reader
BUILD_opencv_dnn_objdetect ON Object Detection using CNNs
BUILD_opencv_dnns_easily_fooled ON Subvert DNNs
BUILD_opencv_dpm ON Deformable Part Model
BUILD_opencv_face ON Face Recognition
BUILD_opencv_fuzzy ON Fuzzy Logic in Vision
BUILD_opencv_freetype ON Drawing text, freetype and harfbuzz
BUILD_opencv_hdf ON Hierarchical Data Storage
BUILD_opencv_line_descriptor ON Line Segment Extract and Match
BUILD_opencv_matlab ON Matlab Mex wrapper
BUILD_opencv_optflow ON Optical Flow
BUILD_opencv_ovis ON OGRE 3D Visualiser
BUILD_opencv_plot ON Plotting
BUILD_opencv_reg ON Image Registration
BUILD_opencv_rgbd ON RGB-Depth Processing module
BUILD_opencv_saliency ON Saliency API
BUILD_opencv_sfm ON Structure from Motion
BUILD_opencv_stereo ON Stereo Correspondence
BUILD_opencv_structured_light ON Structured Light Use
BUILD_opencv_surface_matching ON Point Pair Features
BUILD_opencv_text ON Visual Text Matching
BUILD_opencv_tracking ON Vision Based Object Tracking
BUILD_opencv_xfeatures2d ON Features2D extra
BUILD_opencv_ximgproc ON Extended Image Processing
BUILD_opencv_xobjdetect ON Boosted 2D Object Detection
BUILD_opencv_xphoto ON Extra Computational Photography
BUILD_ANDROID_EXAMPLES ON Build Android examples
BUILD_DOCS ON Build Documentation
BUILD_EXAMPLES ON Build examples
BUILD_PACKAGE ON Build packages
BUILD_PERF_TESTS OFF Build Perf tests
BUILD_TESTS OFF Build tests
BUILD_WITH_DEBUG_INFO OFF Debug option
BUILD_WITH_STATIC_CRT OFF Visual Studio support
BUILD_WITH_DYNAMIC_IPP OFF dynamic IPP support
BUILD_FAT_JAVA_LIB OFF Java libraries
BUILD_ANDROID_SERVICE OFF Android device support
BUILD_CUDA_STUBS OFF CUDA stub support
BUILD_JAVA OFF Java support
INSTALL_CREATE_DISTRIB OFF distrib
INSTALL_C_EXAMPLES ON Install C examples
INSTALL_PYTHON_EXAMPLES ON Install Python examples
INSTALL_ANDROID_EXAMPLES OFF Install Android examples
INSTALL_TO_MANGLED_PATHS OFF Install MANGLEDPATH
INSTALL_TESTS OFF Install tests
ENABLE_NEON:BOOL ON TBB NEON support
ENABLE_FAST_MATH 1 Fast math
BUILD_opencv_python2 ON python2 libraries
BUILD_opencv_python3 ON python3 libraries
BUILD_NEW_PYTHON_SUPPORT ON new python support
CMAKE_INSTALL_PREFIX PREFIX /usr/local
OPENCV_EXTRA_MODULES_PATH EXPATH $PWD/../opencv_contrib-3.4.1/modules
CMAKE_BUILD_TYPE RELEASE Release build

Extra Modules

  • aruco: ArUco and ChArUco Markers -- Augmented reality ArUco marker and "ChARUco" markers where ArUco markers embedded inside the white areas of the checker board.

  • bgsegm: Background segmentation algorithm combining statistical background image estimation and per-pixel Bayesian segmentation.

  • bioinspired: Biological Vision -- Biologically inspired vision model: minimize noise and luminance variance, transient event segmentation, high dynamic range tone mapping methods.

  • ccalib: Custom Calibration -- Patterns for 3D reconstruction, omnidirectional camera calibration, random pattern calibration and multi-camera calibration.

  • cnn_3dobj: Deep Object Recognition and Pose -- Uses Caffe Deep Neural Net library to build, train and test a CNN model of visual object recognition and pose.

  • cvv: Computer Vision Debugger -- Simple code that you can add to your program that pops up a GUI allowing you to interactively and visually debug computer vision programs.

  • datasets: Datasets Reader -- Code for reading existing computer vision databases and samples of using the readers to train, test and run using that dataset's data.

  • dnn_objdetect: Object Detection using CNNs -- Implements compact CNN Model for object detection. Trained using Caffe but uses opencv_dnn modeule.

  • dnns_easily_fooled: Subvert DNNs -- This code can use the activations in a network to fool the networks into recognizing something else.

  • dpm: Deformable Part Model -- Felzenszwalb's Cascade with deformable parts object recognition code.

  • face: Face Recognition -- Face recognition techniques: Eigen, Fisher and Local Binary Pattern Histograms LBPH methods.

  • fuzzy: Fuzzy Logic in Vision -- Fuzzy logic image transform and inverse; Fuzzy image processing.

  • freetype: Drawing text using freetype and harfbuzz.

  • hdf: Hierarchical Data Storage -- This module contains I/O routines for Hierarchical Data Format: https://en.m.wikipedia.org/wiki/Hierarchical_Data_Format meant to store large amounts of data.

  • line_descriptor: Line Segment Extract and Match -- Methods of extracting, describing and latching line segments using binary descriptors.

  • matlab: Matlab Interface -- OpenCV Matlab Mex wrapper code generator for certain opencv core modules.

  • optflow: Optical Flow -- Algorithms for running and evaluating deepflow, simpleflow, sparsetodenseflow and motion templates (silhouette flow).

  • ovis: OGRE 3D Visualiser -- allows you to render 3D data using the OGRE 3D engine.

  • plot: Plotting -- The plot module allows you to easily plot data in 1D or 2D.

  • reg: Image Registration -- Pixels based image registration for precise alignment. Follows the paper "Image Alignment and Stitching: A Tutorial", by Richard Szeliski.

  • rgbd: RGB-Depth Processing module -- Linemod 3D object recognition; Fast surface normals and 3D plane finding. 3D visual odometry

  • saliency: Saliency API -- Where humans would look in a scene. Has routines for static, motion and "objectness" saliency.

  • sfm: Structure from Motion -- This module contains algorithms to perform 3d reconstruction from 2d images. The core of the module is a light version of Libmv.

  • stereo: Stereo Correspondence -- Stereo matching done with different descriptors: Census / CS-Census / MCT / BRIEF / MV.

  • structured_light: Structured Light Use -- How to generate and project gray code patterns and use them to find dense depth in a scene.

  • surface_matching: Point Pair Features -- Implements 3d object detection and localization using multimodal point pair features.

  • text: Visual Text Matching -- In a visual scene, detect text, segment words and recognise the text.

  • tracking: Vision Based Object Tracking -- Use and/or evaluate one of 5 different visual object tracking techniques.

  • xfeatures2d: Features2D extra -- Extra 2D Features Framework containing experimental and non-free 2D feature detector/descriptor algorithms. SURF, SIFT, BRIEF, Censure, Freak, LUCID, Daisy, Self-similar.

  • ximgproc: Extended Image Processing -- Structured Forests / Domain Transform Filter / Guided Filter / Adaptive Manifold Filter / Joint Bilateral Filter / Superpixels / Ridge Detection Filter.

  • xobjdetect: Boosted 2D Object Detection -- Uses a Waldboost cascade and local binary patterns computed as integral features for 2D object detection.

  • xphoto: Extra Computational Photography -- Additional photo processing algorithms: Color balance / Denoising / Inpainting.

#!/bin/sh
cmake \
-D WITH_1394=ON \
-D WITH_AVFOUNDATION=OFF \
-D WITH_CARBON=OFF \
-D WITH_CAROTENE=OFF \
-D WITH_CPUFEATURES=OFF \
-D WITH_VTK=ON \
-D WITH_CUDA=OFF \
-D WITH_CUFFT=OFF \
-D WITH_CUBLAS=OFF \
-D WITH_NVCUVID=OFF \
-D WITH_EIGEN=ON \
-D WITH_VFW=OFF \
-D WITH_FFMPEG=ON \
-D WITH_GSTREAMER=ON \
-D WITH_GTK=ON \
-D WITH_IPP=ON \
-D WITH_HALIDE=ON \
-D WITH_INF_ENGINE=ON \
-D WITH_JASPER=ON \
-D WITH_JPEG=ON \
-D WITH_WEBP=ON \
-D WITH_OPENEXR=ON \
-D WITH_OPENGL=ON \
-D WITH_OPENVX=ON \
-D WITH_OPENNI=OFF \
-D WITH_OPENNI2=OFF \
-D WITH_PNG=ON \
-D WITH_GDCM=ON \
-D WITH_PVAPI=ON \
-D WITH_GIGEAPI=ON \
-D WITH_ARAVIS=ON \
-D WITH_QT=OFF \
-D WITH_WIN32UI=OFF \
-D WITH_QUICKTIME=OFF \
-D WITH_QTKIT=OFF \
-D WITH_TBB=ON \
-D WITH_OPENMP=ON \
-D WITH_CSTRIPES=ON \
-D WITH_PTHREADS_PF=ON \
-D WITH_TIFF=ON \
-D WITH_UNICAP=ON \
-D WITH_V4L=ON \
-D WITH_LIBV4L=ON \
-D WITH_DSHOW=ON \
-D WITH_MSMF=OFF \
-D WITH_XIMEA=ON \
-D WITH_XINE=ON \
-D WITH_CLP=ON \
-D WITH_OPENCL=ON \
-D WITH_OPENCL_SVM=ON \
-D WITH_OPENCLAMDFFT=ON \
-D WITH_OPENCLAMDBLAS=ON \
-D WITH_DIRECTX=OFF \
-D WITH_INTELPERC=OFF \
-D WITH_MATLAB=ON \
-D WITH_VA=ON \
-D WITH_VA_INTEL=ON \
-D WITH_MFX=ON \
-D WITH_GDAL=ON \
-D WITH_GPHOTO2=ON \
-D WITH_LAPACK=ON \
-D WITH_ITT=ON \
-D BUILD_opencv_apps=ON \
-D BUILD_opencv_world=OFF \
-D BUILD_opencv_calib3d=ON \
-D BUILD_opencv_core=ON \
-D BUILD_opencv_cudaarathm=OFF \
-D BUILD_opencv_cudabgsegm=OFF \
-D BUILD_opencv_cudacodec=OFF \
-D BUILD_opencv_cudafeatures2d=0FF \
-D BUILD_opencv_cuclafilters=OFF \
-D BUILD_opencv_cuciaimgproc=OFF \
-D BUILD_opencv_cudalegacy=OFF \
-D BUILD_opencv_cudaobjdetect=OFF \
-D BUILD_opencv_cudaoptflow=OFF \
-D BUILD_opencv_cudastereo=OFF \
-D BUILD_opencv_cudawarping=OFF \
-D BUILD_opencv_cudev=OFF \
-D BUILD_opencv_features2d=ON \
-D BUILD_opencv_flann=ON \
-D BUILD_opencv_hal=ON \
-D BUILD_opencv_highgui=ON \
-D BUILD_opencv_imgcodecs=ON \
-D BUILD_opencv_imgproc=ON \
-D BUILD_opencv_ml=ON \
-D BUILD_opencv_objdetect=ON \
-D BUILD_opencv_photo=ON \
-D BUILD_opencv_sharp=ON \
-D BUILD_opencv_dnn=ON \
-D BUILD_opencv_js=OFF \
-D BUILD_opencv_aruco=ON \
-D BUILD_opencv_bgsegm=ON \
-D BUILD_opencv_bioinspired=ON \
-D BUILD_opencv_ccalib=ON \
-D BUILD_opencv_cnn_3dobj=ON \
-D BUILD_opencv_cvv=ON \
-D BUILD_opencv_datasets=ON \
-D BUILD_opencv_dnn_objdetect=ON \
-D BUILD_opencv_dnns_easily_fooled=ON \
-D BUILD_opencv_dpm=ON \
-D BUILD_opencv_face=ON \
-D BUILD_opencv_fuzzy=ON \
-D BUILD_opencv_freetype=ON \
-D BUILD_opencv_line_descriptor=ON \
-D BUILD_opencv_matlab=ON \
-D BUILD_opencv_optflow=ON \
-D BUILD_opencv_ovis=ON \
-D BUILD_opencv_plot=ON \
-D BUILD_opencv_reg=ON \
-D BUILD_opencv_rgbd=ON \
-D BUILD_opencv_saliency=ON \
-D BUILD_opencv_sfm=ON \
-D BUILD_opencv_stereo=ON \
-D BUILD_opencv_structured_light=ON \
-D BUILD_opencv_surface_matching=ON \
-D BUILD_opencv_text=ON \
-D BUILD_opencv_tracking=ON \
-D BUILD_opencv_xfeatures2d=ON \
-D BUILD_opencv_ximgproc=ON \
-D BUILD_opencv_xobjdetect=ON \
-D BUILD_opencv_xphoto=ON \
-D BUILD_ANDROID_EXAMPLES=OFF \
-D BUILD_DOCS=ON \
-D BUILD_EXAMPLES=ON \
-D BUILD_PACKAGE=ON \
-D BUILD_PERF_TESTS=OFF \
-D BUILD_TESTS=OFF \
-D BUILD_WITH_DEBUG_INFO=OFF \
-D BUILD_WITH_STATIC_CRT=OFF \
-D BUILD_WITH_DYNAMIC_IPP=OFF \
-D BUILD_FAT_JAVA_LIB=OFF \
-D BUILD_ANDROID_SERVICE=OFF \
-D BUILD_CUDA_STUBS=OFF \
-D BUILD_JAVA=OFF \
-D INSTALL_CREATE_DISTRIB=OFF \
-D INSTALL_C_EXAMPLES=ON \
-D INSTALL_PYTHON_EXAMPLES=ON \
-D INSTALL_ANDROID_EXAMPLES=OFF \
-D INSTALL_TO_MANGLED_PATHS=OFF \
-D INSTALL_TESTS=OFF \
-D ENABLE_FAST_MATH=1 \
-D ENABLE_NEON:BOOL=ON \
-D BUILD_opencv_python2=ON \
-D BUILD_opencv_python3=ON \
-D BUILD_NEW_PYTHON_SUPPORT=ON \
-D CMAKE_INSTALL_PREFIX=/usr/local \
-D OPENCV_EXTRA_MODULES_PATH=$PWD/../opencv_contrib-3.4.1/modules \
-D CMAKE_BUILD_TYPE=RELEASE ..
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment