OpenCV installation notes

The following are installation notes on how to install OpenCV library on the platforms indicated.

OpenCV 2.4.2 installation for Microsoft Windows®

Installation instructions for OpenCV 2.X software for Microsoft Windows® by Bernát Gábor on the OpenCV website are very good. Just click on the "OpenCV for Windows" link at the OpenCV downloads page http://opencv.org/downloads.html If you decide to compile the source code yourself, theOpenCV2.4.2 you should use the VC++ 2010 compiler under Windows. If you are using the Visual Studio 2012 IDE do not select the option to convert the project solution to the newer version. The VC++ 2011 compiler will generate lots of errors if you do.

OpenCV installation for Ubuntu 12.04

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-config

Install Image I/O libraries

    sudo apt-get -y install libjpeg62-dev 
    sudo apt-get -y install libtiff4-dev libjasper-dev

Install the GTK dev library

    sudo apt-get -y install  libgtk2.0-dev

Install Video I/O libraries

    sudo apt-get -y install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev

Optional - install support for Firewire video cameras

 sudo apt-get -y install libdc1394-22-dev

Optional - install video streaming libraries

 sudo apt-get -y install libxine-dev libgstreamer0.10-dev libgstreamer-plugins-base0.10-dev 

Optional - install the Python development environment and the Python Numerical library

    sudo apt-get -y install python-dev python-numpy
 

Optional - install the parallel code processing library (the Intel tbb library)

    sudo apt-get -y install libtbb-dev

Optional - install the Qt dev library

    sudo apt-get -y install libqt4-dev

Now download OpenCV 2.4 to wherever you want to compile the source.

    mkdir xxx
    cd xxx 
    wget http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.2/Op...
or 
   wget http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/2.4.3/Op...
    tar -xvf OpenCV-2.4.*.tar.bz2

Create 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

    make

And finally install OpenCV

    sudo make install

OpenCV installation with Python

Python with Ubuntu

To use Python OpenCV scripts with Ubuntu be sure to install NumPy before the "cmake" phase when compiling the OpenCV source code. Ubuntu distribution includes Python so you shouldn't need to install it. See article OpenCV Installation for Ubuntu 12.04, and follow instructions in the Python section.

Python with MS Windows

To use Python with OpenCV 2.4.2 pre-compiled binaries you need to install Python version 2.7.X and NumPy version 1.6. Download Python 2.7 from http://www.python.org website and then right click on the ".exe" file and select "install as administrator". You'll also need to install the NumPy tools from http://numpy.scipy.org/ The downloads link will take you to the Numerical Python project on sourceforge.net. Be sure to download the NumPy 1.6 version for Python 2.7.

Tell your scripts where to find Python

You'll need to tell your Python scripts where to find the OpenCV. You can do that by setting the PYTHONPATH environment variable or including it in your scripts.
For Windows 7
Select menus Control Panel -> System and Security -> System and then click on the "Advanced system settings" link. Click on the "Environment variables" button near the bottom of the menu. Click the "New.." button under System for all users or User variables (for your account only) For "Variable name" enter: "PYTHONPATH" and set the "Variable value": " to where you installed OpenCV and then add "build\python\2.7"; this will be something like "C:\opencv\build\python\2.7".
For Ubuntu
Edit your .bashrc file and add  the line export PYTHONPATH=/usr/local/lib/python2.7