Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to install OpenCV on Windows with Enthought Canopy Python?

I've got the Enthought Canopy Python distribution on Windows, and I'd like to add the OpenCV python bindings.

I have downloaded the latest OpenCV from http://sourceforge.net/projects/opencvlibrary/ but I don't see any setup.py file.

So I'm wondering: What is the best way to install OpenCV on windows to have it working under Enthought Canopy Python?

like image 851
ZZZ Avatar asked Dec 04 '22 10:12

ZZZ


1 Answers

I stumbled on this same issue. Here's what I did:

  1. Unpack the OpenCV distribution into a folder, for example: C:\RPS\python\epd32
  2. Open a text editor and create a one line file that contains the full path where you installed OpenCV + the subdirectory where the python binding lives, for example: C:\RPS\python\epd32\opencv\build\python\2.7.
  3. Save this .pth file in your Enthought Canopy user site packages folder, for example: C:\Users\rsignell\AppData\Local\Enthought\Canopy32\User\Lib\site-packages\opencv.pth

  4. Open Enthought Canopy and try typing import cv2. It should now work!

I do it this way because I like having the whole OpenCV distro on my system, with the examples and other stuff.

But if you don't want the whole OpenCV distro hanging around, you could also just copy <opencv>\build\python\2.7\cv2.pyd into your site-packages directory and then delete the directory that OpenCV unpacked everything into.

Or to avoid extracting everything, you could open the opencv.exe using with something like 7-zip (open inside) and extract just <opencv>\build\python\2.7\cv2.pyd into your site-packages directory.

like image 97
Rich Signell Avatar answered Feb 01 '23 10:02

Rich Signell