Build/Install OpenCV 3.3.0

Following are instructions of how to build/install OpenCV 3.3.0 on Ubuntu (14.04.5 LTS) based Linux machine.

Installation

Make sure that following packages are installed:

sudo apt-get install build-essential pkg-config checkinstall
sudo apt-get install libjpeg-dev libpng-dev zlib1g-dev libtiff4-dev
sudo apt-get install libtbb-dev libeigen3-dev
sudo apt-get install libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev
sudo apt-get install libv4l-dev v4l-utils
sudo apt-get install python-dev python-numpy python-tk
sudo apt-get install libfreetype6-dev libharfbuzz-dev
sudo apt-get install qt5-default
Make sure that CMake is installed too and it can work with SSL. If you don’t know, you should be usingĀ Install cmake with SSL.
sudo apt-get install cmake

Download

mkdir opencv-3.3.0
cd opencv-3.3.0

# Download
wget https://github.com/opencv/opencv/archive/3.3.0.tar.gz -O opencv-3.3.0.tar.gz
wget https://github.com/opencv/opencv_contrib/archive/3.3.0.tar.gz -O opencv_contrib-3.3.0.tar.gz

# Extract source
tar zxvf opencv-3.3.0.tar.gz
tar zxvf opencv_contrib-3.3.0.tar.gz

For ease of development, let’s export some env variables. You should pay attention to OPENCV_INSTALL_DIR. This is a directory where OpenCV will be installed:

export CURRENT_DIR=`pwd`
export OPENCV_SOURCE_DIR=$CURRENT_DIR/opencv-3.3.0
export OPENCV_EXTRA_DIR=$CURRENT_DIR/opencv_contrib-3.3.0
export OPENCV_BUILD_DIR=$CURRENT_DIR/build
export OPENCV_INSTALL_DIR=/usr/local/OpenCV/3.3.0

Build

Setup build directory

mkdir -p $OPENCV_BUILD_DIR

Configure OpenCV

cd $OPENCV_BUILD_DIR

cmake \
 -D CMAKE_BUILD_TYPE=DEBUG \
 -D CMAKE_INSTALL_PREFIX=$OPENCV_INSTALL_DIR \
 -D OpenCV_DIR=$OPENCV_INSTALL_DIR \
 -D INSTALL_C_EXAMPLES=ON \
 -D INSTALL_PYTHON_EXAMPLES=ON \
 -D INSTALL_TESTS=ON \
 -D BUILD_EXAMPLES=ON \
 -D BUILD_TESTS=ON \
 -D WITH_QT=ON \
 -D WITH_OPENGL=ON \
 -D WITH_EIGEN=ON \
 -D WITH_V4L=ON \
 -D BUILD_TBB=ON \
 -D WITH_TBB=ON \
 -D WITH_IPP=ON \
 -D BUILD_opencv_dnn=ON \
 -D BUILD_opencv_python2=ON \
 -D OPENCV_EXTRA_MODULES_PATH=$OPENCV_EXTRA_DIR/modules \
$OPENCV_SOURCE_DIR

Let the CMake to configure OpenCV. Once CMake is done issue

make -j6

Installation

cd $OPENCV_BUILD_DIR
sudo make -j2 install

Configure host machine

Update ldconfig and pkgconfig on the host machine to be aware of the OpenCV 3.3.0

sudo ln -s /usr/local/OpenCV/3.3.0/lib/pkgconfig/opencv.pc /usr/lib/pkgconfig/opencv-3.3.0.pc
sudo ldconfig $OPENCV_INSTALL_DIR/lib

 

Advertisements

Build/Install OpenCV 3.2.0

Following are instructions of how to build/install OpenCV 3.2.0 on Ubuntu (14.04.5 LTS) based Linux machine.

Installation

Make sure that following packages are installed:

sudo apt-get install build-essential pkg-config checkinstall
sudo apt-get install libjpeg-dev libpng-dev zlib1g-dev libtiff4-dev
sudo apt-get install libtbb-dev libeigen3-dev
sudo apt-get install libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev
sudo apt-get install libv4l-dev v4l-utils
sudo apt-get install python-dev python-numpy python-tk
sudo apt-get install libfreetype6-dev libharfbuzz-dev
sudo apt-get install qt5-default
Make sure that CMake is installed too and it can work with SSL. If you don’t know, you should be usingĀ Install cmake with SSL.
sudo apt-get install cmake

Download

mkdir opencv-3.2.0
cd opencv-3.2.0

# Download
wget https://github.com/opencv/opencv/archive/3.2.0.tar.gz -O opencv-3.2.0.tar.gz
wget https://github.com/opencv/opencv_contrib/archive/3.2.0.tar.gz -O opencv_contrib-3.2.0.tar.gz

# Extract source
tar zxvf opencv-3.2.0.tar.gz
tar zxvf opencv_contrib-3.2.0.tar.gz

For ease of development, let’s export some env variables. You should pay attention to OPENCV_INSTALL_DIR. This is a directory where OpenCV will be installed:

export CURRENT_DIR=`pwd`
export OPENCV_SOURCE_DIR=$CURRENT_DIR/opencv-3.2.0
export OPENCV_EXTRA_DIR=$CURRENT_DIR/opencv_contrib-3.2.0
export OPENCV_BUILD_DIR=$CURRENT_DIR/build
export OPENCV_INSTALL_DIR=/usr/local/OpenCV/3.2.0

Build

Setup build directory

mkdir -p $OPENCV_BUILD_DIR

Configure OpenCV

cd $OPENCV_BUILD_DIR

cmake \
 -D CMAKE_BUILD_TYPE=DEBUG \
 -D CMAKE_INSTALL_PREFIX=$OPENCV_INSTALL_DIR \
 -D OpenCV_DIR=$OPENCV_INSTALL_DIR \
 -D INSTALL_C_EXAMPLES=ON \
 -D INSTALL_PYTHON_EXAMPLES=ON \
 -D INSTALL_TESTS=ON \
 -D BUILD_EXAMPLES=ON \
 -D BUILD_TESTS=ON \
 -D WITH_QT=ON \
 -D WITH_OPENGL=ON \
 -D WITH_EIGEN=ON \
 -D WITH_V4L=ON \
 -D BUILD_TBB=ON \
 -D WITH_TBB=ON \
 -D WITH_IPP=ON \
 -D BUILD_opencv_python2=ON \
 -D OPENCV_EXTRA_MODULES_PATH=$OPENCV_EXTRA_DIR/modules \
$OPENCV_SOURCE_DIR

Let the CMake to configure OpenCV. Once CMake is done issue

make -j6

Installation

cd $OPENCV_BUILD_DIR
sudo make -j2 install

Configure host machine

Update ldconfig and pkgconfig on the host machine to be aware of the OpenCV 3.2.0

sudo ln -s /usr/local/OpenCV/3.2.0/lib/pkgconfig/opencv.pc /usr/lib/pkgconfig/opencv-3.2.0.pc
sudo ldconfig $OPENCV_INSTALL_DIR/lib