4

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?

pevogam
  • 536
  • 1
  • 6
  • 15
  • Your example works for me, using version 2.4.2. – Warren Weckesser Feb 01 '13 at 13:46
  • 2
    I don't think you have version 2.4.3. Your output shows the version to be `$Rev: 4557 $`, which looks like a subversion revision. OpenCV stopped using subversion last summer, and 2.4.3 was released in the fall (see http://code.opencv.org/projects/opencv/wiki). – Warren Weckesser Feb 01 '13 at 14:06
  • Thanks, it seemed the I need opencv-devel and opencv-debuginfo rpm packages as well. – pevogam Feb 06 '13 at 16:35
  • 1
    @pevogam Since you've found the answer to your problem, can you post it as an answer, and accept your answer so that this question can be marked as "answered"? – Uyghur Lives Matter Feb 05 '15 at 19:07
  • Check this: http://stackoverflow.com/questions/26059134/adding-modules-from-opencv-contrib-to-opencv First you need intall opencv_contrib: http://stackoverflow.com/questions/18561910/opencv-python-cant-use-surf-sift – Rui Martins Sep 06 '15 at 22:01

2 Answers2

4

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.

pevogam
  • 536
  • 1
  • 6
  • 15
0

You can use also the following line of code:

detector=cv2.xfeatures2d.SURF_create()

You can also set Hessian Threshold.

detector=cv2.xfeatures2d.SURF_create(400)

Here Hessian Threshold=400