Skip to content

How to Build OpenCV 3.2 on Ubuntu 16.04

Aldwin Hermanudin edited this page Apr 7, 2017 · 5 revisions

In Ubuntu 16.04, install the dependencies first and then build the OpenCV 3.2 from source.

sudo apt-get install libopencv-dev build-essential cmake git libgtk2.0-dev pkg-config python-dev python-numpy libdc1394-22 libdc1394-22-dev libjpeg-dev libpng12-dev libjasper-dev libavcodec-dev libavformat-dev libswscale-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev libv4l-dev libtbb-dev libqt4-dev libfaac-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev x264 v4l-utils unzip

Download and Extract the latest source archive for OpenCV 3.2 from https://github.com/opencv/opencv

Enter the unpacked directory. Execute:

mkdir build
cd build/
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D WITH_TBB=ON -D WITH_V4L=ON -D WITH_QT=ON -D WITH_OPENGL=ON ..   
make -j $(($(nproc) + 1))

This completes the build procedure of OpenCV 3.1. (http://docs.opencv.org/3.1.0/d7/d9f/tutorial_linux_install.html)

Installation

(Preferred) Using make

Execute the following:

sudo make install
sudo /bin/bash -c 'echo "/usr/local/lib" > /etc/ld.so.conf.d/opencv.conf'
sudo ldconfig
sudo apt-get update

and reboot the system.

Using checkinstall (this gives incomplete results without the installation by using make)

While you are in the build directory, execute these commands:

sudo apt-get install checkinstall
sudo checkinstall

Fill in the text as required to give the description and the package name. This will create the OpenCV 3.1 package that has a modern install/uninstall option.

acknowledgement : https://github.com/BVLC/caffe/wiki/OpenCV-3.1-Installation-Guide-on-Ubuntu-16.04