问题描述
我正在为OpenCV 2.4.X和OpenCV 3.1使用python绑定,但具有以下简单的两行代码
I am using the python bindings for OpenCV 2.4.X and OpenCV 3.1 but with the following simple two-liner
import cv2
detector = cv2.FeatureDetector_create("SURF")
我得到以下输出:
I get the following output:
Traceback (most recent call last):
File "version_test.py", line 3, in <module>
detector = cv2.FeatureDetector_create("SURF")
AttributeError: 'module' object has no attribute 'FeatureDetector_create'
每个版本中出现此错误的原因是什么?
What are the reasons for this error in each version?
推荐答案
对于2.4.X版本,似乎还需要opencv-devel和opencv-debuginfo(rpm/deb)软件包.
It seemed that I need opencv-devel and opencv-debuginfo (rpm/deb) packages as well for the 2.4.X version.
对于3.1版本,这些功能已被删除,以支持类似的功能
Regarding the 3.1 version, these functions have been removed in favor of functions like
detector = cv2.TYPE_create()
其中TYPE
可以是ORB
或您选择的其他检测器,但不能将SURF
和SIFT
移至 nonfree 软件包.有关更多信息,请参见源.
where TYPE
can be ORB
or other detector of your choosing but not SURF
and SIFT
which have been moved to a nonfree package. For more info check this source.
这篇关于具有AttributeError:'module'对象的OpenCV的Python绑定没有属性'FeatureDetector_create'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!