Install OpenCV 2.4.9 in Ubuntu 14.04, 13.10

OpenCV is the most popular and advanced code library for Computer Vision related applications today, spanning from many very basic tasks (capture and pre-processing of image data) to high-level algorithms (feature extraction, motion tracking, machine learning). It is free software and provides a rich API in C, C++, Java and Python. Other wrappers are available. The library itself is platform-independent and often used for real-time image processing and computer vision.

What’s new in 2.4.9

  • new 3D visualization module ‘viz’
  • performance fixes in ‘ocl’ module
  • fixes in Android Camera
  • improved CUDA support for mobile platforms
  • bugfixes from community
  • 55 reported bugs have been closed
  • 156 pull requests have been merged

See the full ChangeLog for more information

Install OpenCV

Step 1: Make Directory

mkdir opencv

cd /opencv/

Step 2: Remove any pre-installed ffmpeg and x264

sudo apt-get -qq remove ffmpeg x264 libx264-dev

Step 3:  Install Dependenices

[box type=”info” icon=”info”]As reported by kumaranbus, installing ‘libopencv-dev‘ on non nvidia graphics card messes up the drivers. As a workaround for non nvidia cards like AMD/ATI, Radeon, replace libopencv-dev below with ‘ocl-icd-libopencl1‘ which is a generic driver. Please note that I have not tried this out yet as I have no ATI/Radeon cards to test with[/box]

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

– Install ffmpeg

sudo add-apt-repository ppa:mc3man/trusty-media

sudo apt-get update

sudo apt-get install ffmpeg gstreamer0.10-ffmpeg

Step 4: Download and extract OpenCV

wget -O


cd opencv-2.4.9

Step 5: Begin Build Process

Note that this bit would take some time to complete

mkdir build

cd build


make -j2

sudo make install

sudo sh -c 'echo "/usr/local/lib" > /etc/'

sudo ldconfig


– Reboot your machine

Step 6: Example using OpenCV

– Change directory to following location

cd /usr/local/share/OpenCV/samples/c

– Execute following commands

sudo chmod +x

sudo ./

./facedetect "/usr/share/opencv/haarcascades/haarcascade_frontalface_alt.xml" lena.jpg


./facedetect --cascade="/usr/share/opencv/haarcascades/haarcascade_frontalface_alt.xml" lena.jpg


comments powered by Disqus