Skip to content

Instantly share code, notes, and snippets.

@umardx
Last active April 24, 2017 02:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save umardx/dfce1dc74d925629a9eb8ad409740b47 to your computer and use it in GitHub Desktop.
Save umardx/dfce1dc74d925629a9eb8ad409740b47 to your computer and use it in GitHub Desktop.

Installing OpenCV-3.2.0 on Ubuntu 16.04

The following steps have been tested for Ubuntu 16.04 but should work with other distros as well.

Required Packages

  • GCC 4.4.x or later
  • CMake 2.8.7 or higher
  • Git
  • GTK+2.x or higher, including headers (libgtk2.0-dev)
  • pkg-config
  • Python 2.6 or later and Numpy 1.5 or later with developer packages (python-dev, python-numpy)
  • ffmpeg or libav development packages: libavcodec-dev, libavformat-dev, libswscale-dev
  • [optional] libtbb2 libtbb-dev
  • [optional] libdc1394 2.x
  • [optional] libjpeg-dev, libpng-dev, libtiff-dev, libjas

Use the default terminal or any other terminal emulator of your choice to install and update the software.

Step 1: Keep your Ubuntu updated.

sudo apt-get -y update 
sudo apt-get -y upgrade

Step 2: Install the dependencies and build essential

sudo apt-get install -y build-essential
sudo apt-get install -y cmake
2.1: Install GUI support with Qt:
sudo apt-get install -y qt5-default libvtk6-dev
2.2: For media I-O:
sudo apt-get install -y zlib1g-dev libjpeg-dev libwebp-dev libpng-dev libtiff5-dev libjasper-dev libopenexr-dev libgdal-dev
2.3: Install Eigen library and Parallelism library:
sudo apt-get install -y libtbb-dev libeigen3-dev
2.4: Install Python:
sudo apt-get install -y python-dev python-tk python-numpy python3-dev python3-tk python3-numpy
2.5: Install Ant and JDK:
sudo apt-get install -y ant default-jdk
2.6: Doxygen comments are neat, install it:
sudo apt-get install -y doxygen
2.7: This is an optional step - install wget and unzip tools:
sudo apt-get install -y unzip wget

Step 3: Now, download the OpenCV source:

wget https://github.com/opencv/opencv/archive/3.2.0.zip -O OpenCV320.zip

Step 4: Unzip the compressed source, and access the directory:

unzip OpenCV320.zip
cd OpenCV320

Step 5: Create a directory to separate the build files:

mkdir build

.. access it:

cd build

Step 6: Let's build OpenCV now:

cmake -DWITH_QT=ON -DWITH_OPENGL=ON -DFORCE_VTK=ON -DWITH_TBB=ON -DWITH_GDAL=ON -DWITH_XINE=ON -DBUILD_EXAMPLES=ON ..

After this step is concluded successfully, build the executables using:

make -j4

This would take some time:

Step 7: Install OpenCV:

sudo make install

Step 8: Map the library name to the shared library (cache) file:

sudo ldconfig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment