Python bindings for OpenCV with AttributeError: 'module' object has no attribute 'FeatureDetector_create'

pevogam picture pevogam · Feb 1, 2013 · Viewed 10.2k times · Source

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?

Answer

pevogam picture pevogam · Feb 1, 2017

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.