Introduction: Using OpenCV 1.0 With Python 2.5 in Windows XP

Picture of Using OpenCV 1.0 With Python 2.5 in Windows XP

I had a hard time getting openCV(open Computer Vision, by Intel) working with python 2.5, here are instructions and files on how to get this working easily!

We will assume you have python 2.5 installed (from the link above) I will walk through the now fairly straight forward openCV installation process.

ABOUT OPENCV:
"The Open Computer Vision Library is a collection of algorithms and sample code for various computer vision problems."
Basically it has a bunch of tools that let you analyze picture files and live video from a source such as a webcam. I am currently working on a robot for defcon 15.

Step 1: Navigate Your Directories

Picture of Navigate Your Directories

Find out where you have python installed, it is by default C:\Python25\

Once you are there look for 'Lib', inside Lib there should be another directory called 'site-packages'
On this computer I have no other packages installed for python, so it is empty besides a README.txt

Step 2: Copy the Compiled Python Modules Into Site-packages

Picture of Copy the Compiled Python Modules Into Site-packages

Just download the file, unzip and copy the entire /opencv/ directory directly to /site-packages/

as shown in the screenshot...

I compiled the python modules in MSVS 2003 so it works with python 2.5, I am not sure about other versions of python, but it seems like if you compile the python modules in anything besides MSVS 2003, it chokes and dies.

Step 3: Now You Should Be Set

Picture of Now You Should Be Set

To make sure opencv is working well with python navigate to where you installed opencv "C:\Program Files\OpenCV" for me...

Now, samples, then python, and you should be presented with a codeucopia* of example files... a good test file that requires no video input to test the module is working correctly is 'drawing.py'

*made up word

P.S.
If you were only interested in using opencv with python, there is no real reason to install from the original installer besides access to the samples.

Good luck and happy visions!

Comments

cathyna (author)2012-10-02

Muchas gracias =)

Computothought (author)2010-12-16

ubuntu:
sudo apt-get install opencv-doc python-opencv

BillRice (author)2010-04-30

Thanks a lot! Very helpful. Just wondering, does anyone know if openCV 2 works in python 2.5, and if  there are strong reasons to run the new version?

soeinegaudi (author)BillRice2010-05-14

I am having real trubles at the moment with 2.1 !!
First of all, so many things have changed and secondley for some reason the applications I get to work only cause dead windows, that make your screen freeze....
so if you're doing fine with the old version, don't destroy it !!!
if by any chance you know how to juse the new version I'd be glad if you could help me out (I'm really frustrated right now :( ).

puzzledqs (author)2010-02-12

Many Thanks! I didn't have VS2003 installed on my computer, so I failed to complie the python interface myself. I was really ftrustrated... Finally, I get it done with your solution, THX!!!

nakatazhu (author)2010-01-05

 thanks!

karthikmuthuswamy (author)2009-10-13

Thanks for this article. I believe this would not work with Python 2.6. I installed 2.6.3 on my XP. It worked really good once I installed Python 2.5. Really good work and nice of you to have shared this library with the rest of the world!!

yamandu (author)2009-09-05

Really thanks guy! Finally got it!

benmargolis (author)2009-08-13

Hi Nak, I'm getting a strange error, and I was wondering if yo had any ideas what I might be missing. When I try to run one of the samples, I get: Traceback (most recent call last): File "C:\Program Files\OpenCV\samples\python\squares.py", line 8, in from opencv.cv import * File "C:\Python26\lib\site-packages\opencv\__init__.py", line 55, in from cv import * File "C:\Python26\lib\site-packages\opencv\cv.py", line 5, in import _cv ImportError: DLL load failed: The specified module could not be found. I trie dgoogling it, but all I found was to make sure the *.dll's are in the system path, which they are. Do you have any ideas? Thanks,

nak (author)benmargolis2009-08-13

I'm not sure if this will work with python version 2.6, but did you put the openCV directory in the site-packages directory? peace

benmargolis (author)nak2009-08-13

Brilliant! Thank you. I saw some comment that said it worked for 2.6, but it didn't for me. Switching to 2.5 fixed it.

nolanamy (author)2009-07-10

Seriously, thank you. I'm not sure if this is the ideal solution (i.e., maybe Python 2.6 is better than 2.5), but it works. After four hours of frustration trying to figure it out, I found this... took 5 minutes.

nak (author)nolanamy2009-07-11

Glad I could help! :)

selvakumarmuthusamy (author)2008-12-23

I have a doubt , can we use the same in vista also. I think it doesn't work. I tried. It says, side-by-side configuration error. Can you or anybody have any idea about this? I need to use it in vista without having MS Visual Studio.

selvakumarmuthusamy (author)2008-12-12

Hi, Really wonderful work. Thank you very much

nak (author)selvakumarmuthusamy2008-12-12

You're very welcome :)

rob0 (author)2008-11-28

Thanks! This saved me a lot of time hunting - worked great!

nak (author)rob02008-11-28

Thank you for the thank you :) I figured it would help save people a day/a few hours ;)

Feanaro (author)2008-07-30

Thank you for this instructable. I had been looking for a way to get openCV working with python and it just would not work. Cheers mate

alexsolex (author)2007-04-05

Hi I think I can be interested with this. Can you give us some examples of applications ?

About This Instructable

20,962views

15favorites

License:

Bio: Twitter: @mindsforge
More by nak:MSP430 Accelerometer microSD DataloggerHow to make a Filiberto's post cardHomebrew C64 "Paddle" box
Add instructable to: