opencv 实现角点检测 Shi-Tomasi角点检测
角点检测概述
Harris角点检测算法手动实现
opencv中使用Harris角点检测
opencv中使用 Shi-Tomasi角点检测
函数:corners = cv.goodFeaturesToTrack( image, maxCorners, qualityLevel, minDistance[, corners[, mask[, blockSize[, useHarrisDetector[, k]]]]] )
image:源图像
maxCorners:角点数
qualityLevel:质量等级
minDistance:角点之间最小距离
实验:使用Shi-Tomasi检测图像角点
import cv2 as cv
import numpy as np
img = cv.imread('qiqiao.jpg')
gray = cv.cvtColor(img, cv.COLOR_BGR2GRAY)
# Shi-Tomasi角点检测
corners = cv.goodFeaturesToTrack(gray, 12, 0.01, 10)
corners = np.int0(corners) # 12个角点坐标
for i in corners:
# 压缩至一维:[[62,64]]->[62,64]
x, y = i.ravel()
cv.circle(img, (x, y), 4, (0, 0, 255), -1)
cv.imshow('dst', img)
cv.waitKey(0)