OpenCV (Open Source Computer Vision Library) is an open source library of programming functions developed by Intel. It is free for commercial and research use under the open source BSD license. The library is cross-platform, will run on Mac OS X, Windows and Linux. It focuses mainly towards real-time image processing routines and algorithms for software development.
To install OpenCV using the terminal on Ubuntu, you will need some dependencies packages first
$ su -
# apt-get update
# apt-get install build-essential libavformat-dev x264 v4l-utils ffmpeg libcv2.3 libcvaux2.3 libhighgui2.3 python-opencv opencv-doc libcv-dev libcvaux-dev libhighgui-dev libgtk2.0-dev libjpeg-dev libtiff4-dev libjasper-dev libopenexr-dev cmake python-dev python-numpy python-tk libtbb-dev libeigen2-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
OpenCV should be installed in /usr/local/ Installation Directory
You can download the newest version of opencv at http://opencv.org/downloads.html
Download Opencv and untar the package we downloaded
$ wget http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.7/opencv-2.4.7.tar.gz/download
$ tar -xzvf opencv-2.4.7.tar.gz
$ cd opencv-2.4.7
Now you will need root privileges to compile and install opencv
# mkdir build
# cd build
# 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_QT=ON -D WITH_OPENGL=ON ..
# make install
You may also want to compile and view examples
$ cp -r /usr/share/doc/opencv-doc/examples .
$ cd examples
$ cd c
$ sh build_all.sh