0

I'm trying to implement a system that is able to predict the type of scene between 8 cases through images. To do that, I'm implementing the Bag of Visual Words algorithm with different local descriptors and classifiers. I'm testing SIFT and KAZE and its Dense versions (instead of using the keypoints found by the descriptors, I've created a mesh of keypoints all over the image:

Keypoints of the different descriptors

However, when I'm trying to compute the KAZE features from the DENSE keypoints:

# Create KAZE object
KAZE_detector = cv2.KAZE_create(threshold=0.0001)

# Parameter to adjust the size of the keypoints
step_size = 8 

# Read image and transform to gray level
ima=cv2.imread(train_images_filenames[0])
gray=cv2.cvtColor(ima,cv2.COLOR_BGR2GRAY)

# Create the DENSE keypoints
kpt = [cv2.KeyPoint(x, y, step_size) for y in range(0, gray.shape[0], step_size) for x in range(0, gray.shape[1], step_size)]

# Compute the features
kpt, des = KAZE_detector.compute(gray, kpt)

The following error occurs:

---------------------------------------------------------------------------
error                                     Traceback (most recent call last)
/tmp/ipykernel_4330/2348194759.py in <module>
     13 
     14 # Compute the features
---> 15 kpt, des = KAZE_detector.compute(gray, kpt)
     16 

error: OpenCV(4.5.3) /tmp/pip-req-build-afu9cjzs/opencv/modules/features2d/src/kaze/KAZEFeatures.cpp:554: error: (-215:Assertion failed) 0 <= kpts[i].class_id && kpts[i].class_id < static_cast<int>(evolution_.size()) in function 'Feature_Description'

I do not understand why this happens because I use the same exact piece of code for DENSE SIFT and it is working properly.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
David Serrano
  • 295
  • 1
  • 5
  • 14
  • 2
    The constructor has more possible parameters: cv.KeyPoint( x, y, size[, angle[, response[, octave[, class_id]]]] ) the error looks like KAZE needs the class_id for something. Take some research about how KAZE descriptor is conputed and which of these parameters are needed. – Micka Dec 29 '21 at 19:29
  • See comment to this answer: https://stackoverflow.com/a/17982995/2393191 – Micka Dec 29 '21 at 19:31

0 Answers0