简体   繁体   English

使用Enthought Canopy Python在Windows上安装OpenCV的最佳方法?

[英]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. 我在Windows上有Enthought Canopy Python发行版,我想添加OpenCV python绑定。

I have downloaded the latest OpenCV from http://sourceforge.net/projects/opencvlibrary/ but I don't see any setup.py file. 我从http://sourceforge.net/projects/opencvlibrary/下载了最新的OpenCV,但是我没有看到任何setup.py文件。

So I'm wondering: What is the best way to install OpenCV on windows to have it working under Enthought Canopy Python? 所以我想知道:在Windows上安装OpenCV以使其在Enthought Canopy Python下运行的最佳方法是什么?

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 将OpenCV发行版解压缩到一个文件夹中,例如: 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 . 打开文本编辑器并创建一个单行文件,其中包含安装OpenCV + python绑定所在子目录的完整路径,例如: 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 将此.pth文件保存在Enthought Canopy用户站点包文件夹中,例如: C:\\Users\\rsignell\\AppData\\Local\\Enthought\\Canopy32\\User\\Lib\\site-packages\\opencv.pth

  4. Open Enthought Canopy and try typing import cv2 . 打开Enthought Canopy并尝试输入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. 我是这样做的,因为我喜欢在我的系统上安装整个OpenCV发行版,包括示例和其他内容。

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. 但是如果你不想让整个OpenCV发行版<opencv>\\build\\python\\2.7\\cv2.pyd ,你也可以将<opencv>\\build\\python\\2.7\\cv2.pyd到你的site-packages目录中,然后删除OpenCV解压缩所有内容的目录。

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. 或者为了避免提取所有内容,您可以使用7-zip(在内部打开)之类的东西打开opencv.exe,并将<opencv>\\build\\python\\2.7\\cv2.pyd到您的site-packages目录中。

Opencv on Windows has been available pre-built on Windows to Canopy subscribers (ie in the Canopy repository - https://www.enthought.com/products/canopy/package-index/ ) since a few days before this question was posted. 自从这个问题发布前几天,Windows上的Opencv已经预先建立在Canopy订阅者的Windows上(即在Canopy存储库中 - https://www.enthought.com/products/canopy/package-index/ )。 Sorry that I didn't see this question before. 对不起,我之前没有看到这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM