Python 2.7 (Ubuntu/Windows XP) 无法识别 Opencv 2.2
我一直在尝试在 Ubuntu 和 Windows XP 中连接 opencv 和 python。我两件事都失败了。
我读过很多关于“如何安装”它的网页和线程,但没有一个有效(最糟糕的部分是他们都说有点相同)。
步骤(windows xp):
- 默认安装Python 2.7(完美运行)
- 安装PIL和cx_Freeze(也许他们 制造冲突?我不这么认为 :s)
- 默认安装 Opencv 2.2 (OpenCV-2.2.0-win32-vs2010.exe)和 它在 py 内部不被识别,也不被识别 作为 import opencv.cv 也不使用 食谱方式,导入简历(我跳过了 视觉工作室的步骤,因为我会 将其与 python 一起使用)
- 检查路径(没问题,它有 Opencv2.2\bin 的东西)
- 重新检查网页和内容
步骤(ubuntu):
- 让 python 工作
- sudo apt-get install,cmake,make, sudo make install 等(来自
教程) - 同样的事情...模块无法识别
请您帮忙吗?
更新:
我设法安装它并让它被系统识别(我使用http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv 之后就完美运行了)。
现在的问题是当我尝试使用CaptureFromFile时它崩溃了。三天前已经有人举报了,所以现在我在等待。
我会检查其他包装,也许其中一个可以用。
I've been trying to connect opencv and python in both Ubuntu and Windows XP. I've failed on both.
I've read many webpages and threads about "how to install" it but none has worked (the worst part is that they all say kind of the same).
Steps (windows xp):
- Installed Python 2.7 by default (works perfectly)
- Installed PIL and cx_Freeze (may they
create a conflict? I don't think so
:s) - Installed Opencv 2.2 by default
(OpenCV-2.2.0-win32-vs2010.exe) and
it isn't recognized inside a py nor
as import opencv.cv nor using the
cookbook way, import cv (I skipped
the visual studio steps since I'll
use it with python) - Checked path (it's ok, it has the
Opencv2.2\bin thing) - Rechecked webpages and stuff
Steps (ubuntu):
- Had python working
- sudo apt-get install, cmake, make,
sudo make install, etcetc (from the
tutorials) - same thing... module not recognized
Please can you help?
Update:
I managed to install it and have it recognized by the system (I used http://www.lfd.uci.edu/~gohlke/pythonlibs/#opencv and it worked perfectly after that).
The problem now is that it crashes when I try to use CaptureFromFile
. Someone else has reported it 3 days ago so now I wait.
I'll check the other wrappers, maybe one of them will work.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
对于 Windows,请参阅我的网页: http://www.modernmind.org/wiki/OpenCV
对于Ubuntu 你应该只需要 apt-get install python-dev 然后用 Cmake 生成 make 文件,构建它,然后 make install。为了构建 python 绑定,您的系统上需要有 python 头文件,但您可能没有。当您在 Cmake 中运行配置时,请确保您没有在顶部看到任何有关 PYTHON_INCLUDE 未定义的消息。
For windows see my web page: http://www.modernmind.org/wiki/OpenCV
For Ubuntu you should just need to apt-get install python-dev then generate the make files with Cmake, build it and then make install. In order to build the python bindings you need to have the python header files on your system and you probably don't. When you run configure in Cmake make sure that you don't see any messages at the top about PYTHON_INCLUDE not being defined.
要访问库,需要在您使用的 Python 版本中安装 Python 库。从你上面写的内容来看,在我看来你一般安装了 OpenCV,但你没有专门安装 Python 库。这就是为什么它不起作用。
我不确定如何安装 Python 包装器,并且 OpenCV 文档在该信息上有点稀疏。但是,如果您确实构建了它们(并且需要显式打开,文档说)它们似乎最终会出现在 opencv/release/lib 中。
查看 http://opencv.willowgarage.com/wiki/InstallGuide 上的“测试 Python 包装器”
如果仍然没有运气,还有一堆替代的 Python 包装器可用: http://pypi.python.org/pypi?%3Aaction=search&term=opencv&submit=search
也许它们有更好的文档记录。
To access a library it needs a Python library installed in the Python version you are using. From what you write above it seems to me that you install OpenCV in general, but that you don't specifically install the Python library. This is why it doesn't work.
I'm not sure how to install the Python wrappers, and the OpenCV documentation is a bit sparse on that info. But if you did build them (and that needs to be turned on explicitly, says the docs) they seem to end up in opencv/release/lib .
Look at "Testing Python wrappers" on http://opencv.willowgarage.com/wiki/InstallGuide
If there is still no luck, there is a bunch of alternative Python wrappers available: http://pypi.python.org/pypi?%3Aaction=search&term=opencv&submit=search
Maybe they are better documented.