Sunday, 3 February 2013

OpenCV 2.3.1 build for Ubuntu 12.04

download the OpenCv Source package from

Download all the pre-requisite packages

Execute the below commands

apt-get install build-essential
apt-get install cmake
apt-get install pkg-config
apt-get install libpng12-0 libpng12-dev libpng++-dev libpng3
apt-get install libpnglite-dev libpngwriter0-dev libpngwriter0c2
apt-get install zlib1g-dbg zlib1g zlib1g-dev
apt-get install libjasper-dev libjasper-runtime libjasper1
apt-get install pngtools libtiff4-dev libtiff4 libtiffxx0c2 libtiff-tools
apt-get install libjpeg8 libjpeg8-dev libjpeg8-dbg libjpeg-prog
apt-get install ffmpeg libavcodec-dev libavcodec52 libavformat52 libavformat-dev
apt-get install libgstreamer0.10-0-dbg libgstreamer0.10-0  libgstreamer0.10-dev
apt-get install libxine1-ffmpeg  libxine-dev libxine1-bin
apt-get install libunicap2 libunicap2-dev
apt-get install libdc1394-22-dev libdc1394-22 libdc1394-utils
apt-get install swig
apt-get install libv4l-0 libv4l-dev
apt-get install python-numpy
apt-get install libjpeg-progs libjpeg-dev

1.Run cmake-gui
2.Enter the source directory as OpenCV-2.3.1/build_1/2.3/opencv
3.Enter the binary build directory as OpenCV-2.3.1/build_1/2.3/opencv/build_2
4.Select the suitable options and click of configure
Select the suitable support libraries that are required.
5.Select generate to generate the make files /media/LINUX/OpenCV-2.3.1/build_1/2.3/opencv/build_2
make -j4
7.make install

Errors encountered in OpenCv Build
1.cap_ffmpeg_impl.hpp:1128:90: error: ‘av_rescale_q’ was not declared in
this scope
2.Add #include <libavutil/mathematics.h> in the file cap_ffmpeg_impl.hpp before
#include <ffmpeg/avcodec.h>