简体   繁体   English

Python 3是否支持OpenCV?

[英]Is OpenCV supported on Python 3 yet?

I already have part of a program running in Python 3 but I need OpenCV (or SimpleCV), for a robotic vehicle, but I haven't found any install commands that seem to work, other than for Python 2.7. 我已经拥有在Python 3中运行的程序的一部分,但是对于机器人车辆,我需要OpenCV(或SimpleCV),但是除Python 2.7之外,我没有发现任何似乎有效的安装命令。

If it is compatible could you please include instructions (/links to) for installation of the module? 如果兼容,请提供安装模块的说明(/链接到)?

I am using Ubuntu 14. 我正在使用Ubuntu 14。

Maybe a little late to answer, but it's actually supported on OpenCV version 3 (in alpha state nowadays). 也许回答的时间有点晚了,但是实际上OpenCV版本3支持该功能(如今处于Alpha状态)。 I have successfully managed to install it, on MacOS, but I guess it would be similar on Ubuntu. 我已经成功地在MacOS上安装了它,但是我想它在Ubuntu上会类似。 Now you have separated options for python2 and python3 when using Cmake. 现在,当使用Cmake时,已经为python2和python3设置了单独的选项。 So you'll have to set those to make it work. 因此,您必须设置它们才能使其正常运行。 That's all I needed to set: 这就是我需要设置的所有内容:

  • BUILD_opencv_python3 BUILD_opencv_python3
  • PYTHON3_LIBRARY PYTHON3_LIBRARY
  • PYTHON3_INCLUDE_DIR PYTHON3_INCLUDE_DIR
  • PYTHON3_INCLUDE_DIR2 PYTHON3_INCLUDE_DIR2
  • PYTHON3_NUMPY_INCLUDE_DIRS PYTHON3_NUMPY_INCLUDE_DIRS
  • ... ...

Here you can find more detailed description: Link 在这里您可以找到更详细的描述: 链接

Luigolas is correct that OpenCV 3.0 supports Python 3.x bindings. Luigolas是正确的,OpenCV 3.0支持Python 3.x绑定。 It was in release candidate status since April and the production version was released on 4 June 2015. Unfortunately for some reason the downloadable installation program on the OpenCV site does not contain a Python 3.x-compatible cv2.pyd file. 自4月起它处于候选发布状态,生产版本于2015年6月4日发布。不幸的是,由于某些原因,OpenCV站点上的可下载安装程序不包含与Python 3.x兼容的cv2.pyd文件。

OP asked about Ubuntu but for those requiring a Windows installer, use Christoph Gohlke's site, which maintains Windows binaries for many Python packages, including OpenCV 3.0 with Python 3.x bindings. OP询问了有关Ubuntu的信息,但对于需要Windows安装程序的用户,请使用Christoph Gohlke的站点,该站点维护许多Python软件包(包括带有Python 3.x绑定的OpenCV 3.0)的Windows二进制文件。 Visit: 访问:

http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv

To install, just download the 64-bit or 32-bit .whl file appropriate for your system, then run pip install [filename] . 要安装,只需下载适合您系统的64位或32位.whl文件,然后运行pip install [filename] Then the instruction import cv2 should work in your Python 3.x interpreter. 然后,指令import cv2应该可以在您的Python 3.x解释器中使用。

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

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