Install OpenCV with Python 2.7 on Windows

 Installing OpenCV on Windows with Python 2.7

OpenCV is released under a BSD license and hence it’s free for both academic and commercial use. It has C++, C, Python 2.7 (above) and Java interfaces and supports Windows, Linux, Mac OS, iOS, and Android. OpenCV was designed for computational efficiency and with a strong focus on real-time applications. Written in optimized C/C++, the library can take advantage of multi-core processing. Enabled with OpenCL, it can take advantage of the hardware acceleration of the underlying heterogeneous compute platform. Adopted all around the world, OpenCV has more than 47 thousand people of the user community and estimated the number of downloads exceeding 9 million. Usage ranges from interactive art to mines inspection, stitching maps on the web or through advanced robotics.

Installing OpenCV from prebuilt binaries

  1. Below Python packages are to be downloaded and installed to their default locations.
    1. Python-2.7.5.
    2. Numpy 1.8.
  2. Install all packages into their default locations. Python will be installed to C:/Python27/.
  3. After installation, open Python IDLE. Enter import numpy and make sure Numpy is working fine.
  4. Download latest OpenCV release from sourceforge site and double-click to extract it.
  5. Goto opencv/build/python/2.7 folder.
  6. Copy cv2.pyd to C:/Python27/lib/site-packages.
  7. Open Python IDLE and type following codes in Python terminal.

               >>> import cv2

               >>> print cv2.__version__

If the results are printed out without any errors, congratulations !!! You have installed OpenCV-Python successfully.

Possible Errors while Installation of OpenCV

There are following two most common type of errors while installation:

ERROR 1: ImportError: DLL load failed: %1 is not a valid Win32 application

This error will show something like this:

>>> import cv2
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
ImportError: DLL load failed: %1 is not a valid Win32 application.

SOLUTION: Try copying  the 32-bit version of cv2.pyd in step 6 of installation process mentioned above. The reason is that your installed Python 2.7 version is 32-bit but you might be trying to use 64-bit OpenCV cv2.pyd file. So there is a compatibility issue.

 

ERROR 2:OpenCV 2.4.8: module compiled against API version 9

This error looks something like the following:

import cv2
   RuntimeError: module compiled against API version 9 but this version 
   of numpy is 7

   Traceback (most recent call last):
   File "<pyshell#2>", line 1, in <module>
   import cv2
   ImportError: numpy.core.multiarray failed to import

SOLUTION: The version of numpy in the tutorial is at OpenCV website is version 7, but now the team is using version 9 (but numpy team name it 1.8 publicly). So, simply update your numpy installation. If you have used my “numpy 1.8” link above, then there should not be any problem.

For convenience, download the latest version, check here

Please feel free to leave a comment or question below.

I am Ranjit Singh. I love working with online money making software. You will find great tricks and premium software cracks on my blog.
About Ranjit Singh
I am Ranjit Singh. I love working with online money making software. You will find great tricks and premium software cracks on my blog.

3 Comments

  1. Excellent web site. Lots of helpful info here. I am sending it to a few buddies ans additionally sharing in delicious.
    And certainly, thanks to your effort!

    Reply
  2. I’m really impressed with your writing skills and also with the layout on your weblog.
    Is this a paid theme or did you customize it yourself?
    Anyway keep up the excellent quality writing, it’s
    rare to see a great blog like this one nowadays.

    Reply

Your email address will not be published.

Page generated in 0.749 seconds. Stats plugin by www.blog.ca