opencv python Shi-Tomasi角点检测

Shi-Tomasi Corner Detector & Good Features to Track

cv2.goodFeaturesToTrack(image, maxCorners, qualityLevel, minDistance[, corners[, mask[, blockSize[, useHarrisDetector[, k]]]]])

opencv通过Shi-Tomasi方法(或Harris角点检测,如果你指定它)在图像中找到N个最强角,图像应该是灰度图像,需要指定要查找的角点数,需要指定质量等级,该等级是0-1之间的值,表示低于每个人被拒绝的角落的最低质量,需要供检测到的角之间的最小欧氏距离.

利用所有这些信息,该函数可以在图像中找到角点。 低于质量水平的所有角落都被拒绝,然后它根据质量按降序对剩余的角进行排序.

import numpy as np
import cv2
from matplotlib import pyplot as plt

img = cv2.imread('img5.png')
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)

corners = cv2.goodFeaturesToTrack(gray,25,0.01,10)
corners = np.int0(corners)

for i in corners:
    x,y = i.ravel()
    cv2.circle(img,(x,y),3,255,-1)

plt.imshow(img),plt.show()

opencv python Shi-Tomasi角点检测

相关推荐