How to install OpenCV with Python for Windows?

What is OpenCV?

OpenCV stands for Open Source Computer Vision. It is a library of programming functions mainly aimed at real-time computer vision, developed by Intel Russia research center. As the name suggests, it is free for use under the open source BSD license. The library is cross platform i.e. it can  be used & merged along with the other programming languages. It focuses mainly on real-time image processing. At the time of development, it is written in C/C++.
Python is highly compatible with OpenCV, this is the reason for the selection of Python with OpenCV by most of the developers working on Image Processing.
For further information about OpenCV, one can refer the official website www.opencv.org

Installation guide for OpenCV with Python:

Step I: Download & Install Python

First download Python from www.python.org/download/windows for Windows & install Python 2.7. Leave all settings as default. In that case, Python will be installed in default folder C:\Python27\

Step II: Download & Install Numpy

Now download Numpy from www.scipy.org/scipylib/download.html . Again leave everything default. Numpy will find Python directory and will be installed to most appropriate folder.

Step III: Download & Install OpenCV

Download OpenCV from www.opencv.org/downloads.html & double-click OpenCV.exe. It will ask for the extraction folder. Let it as  just C:\. It will extract all files to C:\opencv\  . Wait until everything is extracted.

Step IV: Copy files to Python from OpenCV

Now copy everything from the folder C:\opencv\build\python\x86\2.7\ ( most probably, there will be only one file i.e. cv2.pyd ) and paste it in the folder C:\Python27\Lib\site-packages\

Step V: Run Python IDLE

Now open “Python IDLE” ( from Start > All Programmes > Python 2.7 > Python IDLE ) and just type following :
import cv2
This will import the cv2 module.

P.S. You can also run the sample files from the folder C:\opencv\samples\python2 by just double-clicking on it.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s