Google+ My Python Projects: Installing OpenCV module on Python Google+

Monday, July 15, 2013

Installing OpenCV module on Python

This post discusses the installation of OpenCV 2 in python2.7.3

Caution: cv.py belongs to outdated version of OpenCV development.Use OpenCV2 versions with cv2.py module

(I personally think the Combination of Python2.7 and OpenCV 2.4.2 works best, Other versions of OpenCV are reported to have problems,and no OpenCV python library is available for versions above python2.7)

As a newbee I didn't had a clue how to install OpenCV on my Computer.And I struggled for days searching 'how to' on the internet.After visiting several websites and posts I got it all straight.So I am sure this post will be very helpful for newbs'

Installing OpenCV module on Linux like systems:

I am using Ubuntu12.04 LTS (So only installation of OpenCV in Ubuntu 12.04 is verified personally,though you can try same procedure for other linux distributions).

Easy but obsolete,with standard features:

You can use synaptic manager/software center of Ubuntu(or any other linux with apt package manager) to search python-opencv.But this repository provides only OpenCV2.3 you can install these if you want,It is the easiest way.(there are some difference between new versions of OpenCV and this version,but most of the programs I wrote worked on both versions of OpenCV)

Bit difficult but Newest,with advanced features (build the whole OpenCV library using cmake):

I worried if having obsolete version of OpenCV would make problems.So I searched internet once again relentlessly and finally found sirivy's blog,a superb blog describing the procedure.

 Just a note for OpenCV 2.4.2 installation on Ubuntu 12.04 | Sirivy's Weblog

Though I was a beginner in Ubuntu,the blog explained the procedure in way anyone with little bit of command line experience can follow them.


Installing OpenCV module on Python in Windows :


Easy way:

Actually there is not much of "installing" needed in this shortcut.

Download the OpenCV installer from www.opencv.org. this file last I checked was of 291MB for the newest version of OpenCV 2.4.6. This is a self extracting .exe file.And the fun part is you need only a cv2.pyd file of about 8MB for using Python Module,which unfortunately is binded inside the exe file.

Go to opencv>build>python>2.7 you will find the cv2.pyd compiled python file just copy it and paste it inside site-packages directory of your python2.7 installation usually found in C:/>Python27>Libs>site-packages

And now open the Python IDE you use(IDLE/other) and type

import cv2

hit enter,if it returns nothing Hurray! now you have the cv2 module installed else check if the directories are correct.

Hard Way (building library):

Here I can't help you folks.I have never done it in windows,I converted to Ubuntu a year ago,and never had to look back again.:)

Linux (Ubuntu) Vs. Windows :

Though it easier to "install" the OpenCV module on windows,it seems that accessing video with audio channel using OpenCV library seems impossible from Windows.
Whereas In ubuntu it works like magic.If your requirement is to access Image files alone you may stick with Windows.

So in the next post we can start playing around with OpenCV.And as always doubts/feedbacks in the form of comments are welcome.

No comments:

Post a Comment