2

I'm trying to use the STAR detector in openCV 3, and it's throwing an error:

import cv2 image = cv2.imread('grand_central_terminal.png') gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) star = cv2.xfeatures2d.StarDetector_create() (kps, descs) = star.detectAndCompute(gray, None) print("# of keypoints: {}".format(len(kps))) # should be 459 

The error it gives is:

Traceback (most recent call last): File "quiz.py", line 8, in <module> (kps, descs) = star.detectAndCompute(gray, None) cv2.error: /home/travis/miniconda/conda-bld/work/opencv-3.1.0/modules/features2d/src/feature2d.cpp:144: error: (-213) in function detectAndCompute 

Here's the image: grand_central_terminal.png

Running on ubuntu 16.04LTS 64-bit with python 3.5 and anaconda.

1 Answer 1

5

The error code -213 you are receiving indicates that the detectAndCompute method is not implemented for the STAR detector. That is because STAR is only a feature detector, not a combination detector and descriptor. Your code can be fixed by calling the detect method instead:

kps = star.detect(gray) 
Sign up to request clarification or add additional context in comments.

2 Comments

I see, so how is the star.detectAndCompute supposed to work?
star.detectAndCompute isn't supposed to work. It seems like an unfortunate accident the method exists at all. Some things in the xfeatures2d module are both detectors and descriptors (like ORB or SIFT), and those make use of detectAndCompute. STAR is only a feature detector, but will not compute descriptors for those keypoints.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.