Sunday, April 14, 2013

How to install opencv(cv2) with python bindings in Linux - Ubuntu/Fedora


  1. Install gcc, g++/gcc-c++, cmake (apt-get or yum, in case of yum use gcc-c++)#apt-get install gcc, g++, cmake
  2. Downlaod latest opencv from openCV's website (http://opencv.org/downloads.html).
  3. Untar it #tar - xvf opencv-*
  4. Inside the untarred folder make a new folder called "release" (or any folder name) and run this command in it
    #"cmake -D
    CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON -D BUILD_EXAMPLES=ON .."


    the ".." will pull files from the parents folder and will get the system ready for installation for your specific platform.
  5. in the release folder  (#cd release) run #make
  6. After about 3-4 mins (obviously could be faster on your machine) of make processing when its finished run #make install
That's it, now go to python and try ">>> import cv2" you should not get any error message.
I've tested it on python 2.7, should be virtually similar to python 3.x.