opencv 3.0.0-dev python 绑定无法正常工作

opencv 3.0.0-dev python bindings not working properly

我在 ubuntu 14.04.02,我安装并更新了 python、cython 和 numpy。 我从 http://github.com/itseez/opencv 中提取了最新的 open cv 资源,根据文档编译... 当尝试 运行 我从 https://github.com/shantnu/FaceDetect/ 中提取的 python 来源时 它给了我以下错误:

modprobe: FATAL: Module nvidia not found. Traceback (most recent call last): File "face_detect.py", line 21, in flags = cv2.cv.CV_HAAR_SCALE_IMAGE AttributeError: 'module' object has no attribute 'cv'

为了确保我有 python 绑定,我在终端中输入了以下内容: python

import cv2
cv2.__version__

它返回了以下内容 '3.0.0-开发'

它有什么问题吗?

在 opencv3.0 中删除了 cv2.cv 子模块,同时更改了一些常量。

请改用cv2.CASCADE_SCALE_IMAGE

(执行 help(cv2) 查看更新后的常量)

对这个问题深表歉意,但上面的方法对我不起作用,我找到了一个替代方法 "solution",但它可能有不需要的副作用,因为我了解 SFA 关于 openCV 的知识。

简单的解决方案就是将其设置为 0。

  # Detect faces in the image
faces = faceCascade.detectMultiScale(
    gray,
    scaleFactor=1.1,
    minNeighbors=5,
    minSize=(30, 30),
#    flags = cv2.cv.CV_HAAR_SCALE_IMAGE
    flags = 0
)

如您所见...我只是将其设置为 0 并可以继续我的生活。

我尝试了所有组合,但无法使 CASCADE_SCALE_IMAGE 正常工作。

This openCV doco explaination 给我 nadda,zip,除了混乱什么都没有。

flags – Parameter with the same meaning for an old cascade as in the function cvHaarDetectObjects. It is not used for a new cascade.

这就解决了...

无论如何,openCV 上的示例将其硬编码为 0。