import cv2有效但导入cv2.cv为cv无法正常工作

时间:2012-09-06 02:10:47

标签: python opencv simplecv

我认为sys路径是正确的,cv.pyd和cv.pyd位于c:\ OpenCV2.3 \ build \ Python \ 2.7 \ Lib \ site-packages。

>>> import sys
>>> sys.path
['', 'C:\\Python27\\Lib\\idlelib', 'C:\\Python27\\lib\\site-packages\\pil-1.1.7-py2.7-win32.egg',     'C:\\Python27\\lib\\site-packages\\cython-0.17-py2.7-win32.egg', 'C:\\Python27\\lib\\site-packages\\pip-1.2-py2.7.egg', 'c:\\OpenCV2.3\\build\\Python\\2.7\\Lib\\site-packages', 'C:\\Python27\\python27.zip', 'C:\\Python27\\DLLs', 'C:\\Python27\\lib', 'C:\\Python27\\lib\\plat-win', 'C:\\Python27\\lib\\lib-tk', 'C:\\Python27', 'C:\\Python27\\lib\\site-packages', 'C:\\Python27\\lib\\site-packages\\IPython\\extensions']

导入cv或cv2似乎没问题,但导入cv2.cv不是

>>> import cv
>>> import cv2.cv as cv

Traceback (most recent call last):
  File "<pyshell#4>", line 1, in <module>
    import cv2.cv as cv
ImportError: No module named cv
>>> import cv2
>>> cv.NamedWindow("camera", 1)

...

导入错误的原因是什么?

1 个答案:

答案 0 :(得分:1)

我有同样的问题。这是OpenCV Engine的问题。从https://github.com/thumbor/opencv-engine/releases/tag/1.0.1下载OpenCV引擎并将其保存为\ Python27 \ Lib \ site-packages.use cv2.cv中的engine.py而不是cv2 .cv as cv。