如何减少哈里斯角点检测器检测到的点数?

How to decrease number of points detected by Harris Corner Detector?

我正在使用 Harris 角点检测器进行特征检测。我正在使用的代码如下所示。结果是检测到超过 10000 个关键点。如何将检测到的关键点数量减少到 1000 左右并确保它是精确的?


import numpy as np
import cv2 as cv
img = cv.imread('img.jpg')

half = cv.resize(img, (1200, 800), fx=0.1, fy=0.1)

gray = cv.cvtColor(half, cv.COLOR_BGR2GRAY)

gray = np.float32(gray)
dst = cv.cornerHarris(gray, 2, 3, 0.20)

dst = cv.dilate(dst, None)

half[dst > 0.01 * dst.max()] = [0, 0, 255]

num_corners = np.sum(dst > 0.01 * dst.max())

print(num_corners)

cv.imshow('dst', half)

cv.waitKey(0)
cv.destroyAllWindows()

在代码的以下行中使用值“0.01”。增加它以减少检测到的角点数。

half[dst > 0.01 * dst.max()] = [0, 0, 255]

num_corners = np.sum(dst > 0.01 * dst.max())

Information about Harris Corner Detection is available here.