我在哪里可以获得 Python 的 OpenCV?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2172573/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Where can i get OpenCV for python?
提问by appusajeev
Where can i get OpenCV for python?What are the pre-requisites?? i tried to install opencv-python through synaptic package manager but Python says
我在哪里可以获得 Python 的 OpenCV?先决条件是什么??我试图通过突触包管理器安装 opencv-python 但 Python 说
No module named CVtypes
没有名为 CVtypes 的模块
采纳答案by mipata
CVTypes is a third party implementation that essentially wraps python around objects written in C, the language that OpenCV is written in (along with C++). If you want to use that, you will have to download and install it separately, as it is not part of the standard repositories of Ubuntu's Synaptic package manager that I know of at this time (I assume you are on Ubuntu because you mentioned 'Synaptic', Ubuntu's package manager).
CVTypes 是第三方实现,它本质上将 Python 包裹在用 C 编写的对象周围,C 是 OpenCV 编写的语言(以及 C++)。如果你想使用它,你将不得不单独下载并安装它,因为它不是我目前所知道的 Ubuntu 的 Synaptic 包管理器的标准存储库的一部分(我假设你在 Ubuntu 上,因为你提到了'Synaptic ',Ubuntu 的包管理器)。
However, there is an official python interface for OpenCV that is included in the OpenCV SVN repository and build packages. When installing version 1.0 from the package manager in Ubuntu, the python modules will be installed in the following directory:
但是,OpenCV 的官方 Python 接口包含在 OpenCV SVN 存储库和构建包中。在 Ubuntu 中从包管理器安装 1.0 版时,python 模块将安装在以下目录中:
/usr/lib/pymodules/python2.6/opencv
/usr/lib/pymodules/python2.6/opencv
Ensure that is part of your PYTHONPATH environment variable and you should be able to import the modules as such:
确保它是您的 PYTHONPATH 环境变量的一部分,并且您应该能够像这样导入模块:
from opencv.cv import *
from opencv.highgui import *
回答by whatnick
OpenCV over time has accumulated numerous Python bindings, mostly due to the strange way arrays are represented in OpenCV (IMHO). Here is a short list:
随着时间的推移,OpenCV 积累了许多 Python 绑定,主要是由于 OpenCV 中数组的奇怪表示方式(恕我直言)。这是一个简短的列表:
Choose which one you want to use and keep it consistent and upto date. I personally prefer the classic WillowGarage version[listed last] over its fancier cousins since it has most development and test muscle behind it.
选择您要使用的一个并保持一致和最新。我个人更喜欢经典的 WillowGarage 版本[最后列出],而不是其更高级的表兄弟,因为它背后有最多的开发和测试力量。
回答by tovmeod
回答by meduz
check your openCV
version. Version 2 needs a simple
检查您的openCV
版本。版本 2 需要一个简单的
import cv
you may have a look at the samples/python
folder.
你可以看看samples/python
文件夹。
回答by kb.
Tried the official website? http://opencv.willowgarage.com/wiki/Welcome
回答by TangLeepBoon
this webpage explains in great depth on the installation http://opencvpython.blogspot.com/2012/05/install-opencv-in-windows-for-python.html
这个网页对安装进行了深入的解释 http://opencvpython.blogspot.com/2012/05/install-opencv-in-windows-for-python.html
after the installation try out the samples provided by opencv\samples\python2
安装后试用opencv\samples\python2提供的样例