wordsforthewise
wordsforthewise

Reputation: 15777

How to use STAR detector in openCV 3 with python?

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.

Upvotes: 2

Views: 6554

Answers (1)

Aurelius
Aurelius

Reputation: 11329

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)

Upvotes: 5

Related Questions