问题
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?
回答1:
It seemed that I need opencv-devel and opencv-debuginfo (rpm/deb) packages as well for the 2.4.X version.
Regarding the 3.1 version, these functions have been removed in favor of functions like
detector = cv2.TYPE_create()
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.
来源:https://stackoverflow.com/questions/14646692/python-bindings-for-opencv-with-attributeerror-module-object-has-no-attribute