To install OpenCV 2.4.2 or 2.4.3 on the Ubuntu 12.04 operating system, first install a developer environment to build OpenCV.
sudo apt-get -y install build-essential cmake pkg-configInstall Image I/O libraries
sudo apt-get -y install libjpeg62-dev sudo apt-get -y install libtiff4-dev libjasper-devInstall the GTK dev library
sudo apt-get -y install libgtk2.0-devInstall Video I/O libraries
sudo apt-get -y install libavcodec-dev libavformat-dev libswscale-dev libv4l-devOptional - install support for Firewire video cameras
sudo apt-get -y install libdc1394-22-devOptional - install video streaming libraries
sudo apt-get -y install libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-devOptional - install the Python development environment and the Python Numerical library
sudo apt-get -y install python-dev python-numpyOptional - install the parallel code processing library (the Intel tbb library)
sudo apt-get -y install libtbb-devOptional - install the Qt dev library
sudo apt-get -y install libqt4-devNow download OpenCV 2.4 to wherever you want to compile the source.
mkdir xxx cd xxx wget or wget tar -xvf OpenCV-2.4.*.tar.bz2Create and build directory and onfigure OpenCV with cmake. Don't forget the .. part at the end of cmake cmd !!
cd OpenCV-2.4.* mkdir build cd build cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -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 ..Now compile it
makeAnd finally install OpenCV
sudo make install