opencv 3.0.0-dev python 绑定不能正常工作
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30013009/
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
opencv 3.0.0-dev python bindings not working properly
提问by Aly Shmahell
I am on ubuntu 14.04.02, i have python, cython and numpy installed and updated. i pulled the latest sources of open cv from http://github.com/itseez/opencv, compiled according to the documentation... when trying to run the python source i pulled from https://github.com/shantnu/FaceDetect/it's giving me the following error :
我在 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'
modprobe:致命:未找到模块 nvidia。回溯(最近一次调用):文件“face_detect.py”,第 21 行,在 flags = cv2.cv.CV_HAAR_SCALE_IMAGE AttributeError: 'module' object has no attribute 'cv'
to make sure i have the python bindings i typed the following in the terminal: python
为了确保我有 python 绑定,我在终端中输入了以下内容:python
import cv2
cv2.__version__
it returned the following '3.0.0-dev'
它返回了以下“3.0.0-dev”
what could be wrong with it?
它有什么问题?
采纳答案by berak
the cv2.cv submodule got removed in opencv3.0, also some constants were changed.
在 opencv3.0 中删除了 cv2.cv 子模块,也更改了一些常量。
please use cv2.CASCADE_SCALE_IMAGE instead
请改用 cv2.CASCADE_SCALE_IMAGE
(do a help(cv2)
to see the updated constants)
(做一个help(cv2)
查看更新的常量)
回答by StuvdG
Apologies for the bump, but the above did not work for me, and I found an alternate "solution", but it may have unwanted side effects, given I know SFA about openCV.
为这个问题道歉,但以上对我不起作用,我找到了一个替代的“解决方案”,但它可能有不需要的副作用,因为我知道关于 openCV 的 SFA。
The simple solution is just set it to 0.
简单的解决方案是将其设置为 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 )
faces = faceCascade.detectMultiScale( gray, scaleFactor=1.1, minNeighbors=5, minSize=(30, 30), # flags = cv2.cv.CV_HAAR_SCALE_IMAGE flags = 0 )
As you can see... i just set it to 0 and could move on with my life.
正如你所看到的......我只是将它设置为 0 并且可以继续我的生活。
I tried all number of combinations, and I couldn't get the CASCADE_SCALE_IMAGE working.
我尝试了所有组合,但无法让 CASCADE_SCALE_IMAGE 工作。
This openCV doco explainationgives me nadda, zip, nothing but confusion.
这个 openCV doco 解释给了我 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.
flags – 与函数 cvHaarDetectObjects 中的旧级联具有相同含义的参数。它不用于新的级联。
That cleared it up...
那就清零了...
Anyway, the example on openCV hard codes it to 0.
无论如何,openCV 上的示例将其硬编码为 0。