Using OpenCV 1.0 With Python 2.5 in Windows XP




Introduction: Using OpenCV 1.0 With Python 2.5 in Windows XP

About: Twitter: @mindsforge

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.

"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

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

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

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

*made up word

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!



    • Metalworking Contest

      Metalworking Contest
    • Water Contest

      Water Contest
    • Creative Misuse Contest

      Creative Misuse Contest

    20 Discussions

    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?

    1 reply

    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 :( ).

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

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

    Really thanks guy! Finally got it!

    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\", line 8, in from import * File "C:\Python26\lib\site-packages\opencv\", line 55, in from cv import * File "C:\Python26\lib\site-packages\opencv\", 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,

    2 replies

    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

    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.

    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.

    1 reply

    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.

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

    1 reply

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

    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

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