This post is intended to aid linux enthusiasts to install the latest OpenCV version 2.4.9 on their computer. The method is tested in Ubuntu 12.04 desktop and can also be applied to Mint and Debian users. Eventhough the method mentioned below will overwrite any existing OpenCV installation on your system, it is advised to remove any previous installation.
Open a terminal and type the following to update the source list. And install some packages required.
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install build-essential libgtk2.0-dev libjpeg-dev libtiff4-dev libjasper-dev libopenexr-dev cmake python-dev python-numpy python-tk libtbb-dev libeigen3-dev yasm libfaac-dev libopencore-amrnb-dev libopencore-amrwb-dev libtheora-dev libvorbis-dev libxvidcore-dev libx264-dev libqt4-dev libqt4-opengl-dev sphinx-common texlive-latex-extra libv4l-dev libdc1394-22-dev libavcodec-dev libavformat-dev libswscale-dev default-jdk ant libvtk5-qt4-dev
For downloading the source use the following command
git clone https://github.com/Itseez/opencv.git
Decompress the file obtained above using the below command.
Now all we need is to build the OpenCV for your system. For this use the following commands
mkdir build && cd build
Configure with additional options
cmake -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_IPP=OFF -D CMAKE_INSTALL_PREFIX=/usr ..
Note: Above command should not return any error. If returned with error try disabling some options eg: BUILD_EXAMPLES=OFF
Finally install the build files to your system.
sudo make install
For testing the installation try to compile and run a program as in our previous post.