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?

5
  • Your example works for me, using version 2.4.2. Commented Feb 1, 2013 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 code.opencv.org/projects/opencv/wiki). Commented Feb 1, 2013 at 14:06
  • Thanks, it seemed the I need opencv-devel and opencv-debuginfo rpm packages as well. Commented Feb 6, 2013 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"? Commented Feb 5, 2015 at 19:07
  • Check this: stackoverflow.com/questions/26059134/… First you need intall opencv_contrib: stackoverflow.com/questions/18561910/… Commented Sep 6, 2015 at 22:01

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

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

1 Comment

Why does this fix the problem? Also, please format the code so it's easily readable.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.