Joseph Yu
Joseph Yu

Reputation: 133

OpenCv Python SIFT-How to reduce the number of Keypoints?

I am wondering if there is a way to set the max number of the keypoints extracted from each image using OpenCV Python. I would prefer to let the number of keypoints vary from image to image instead of just setting the same number of keypoints for each image.

for pic in Training:
  kp, des = cv2.SIFT().detectAndCompute(pic, None)
  descriptors = np.append(descriptors, des)

Upvotes: 1

Views: 4959

Answers (1)

Joseph Yu
Joseph Yu

Reputation: 133

Nevermind, I just figured out how to do it. We can put the maximum number of keypoints we want within the cv2.SIFT(max) function, say, we want the maximum of keypoints for each image to be 150.

for pic in Training:
 kp, des = cv2.SIFT(150).detectAndCompute(pic, None)
 descriptors = np.append(descriptors, des)

array([ 150., 99., 150., 150., 151., 150., 150., 150., 150., 150., 150., 128.])

Upvotes: 8

Related Questions