harris检测是一个带有这些分数的灰度图像。
cv.cornerHarris()
参数 | 描述 |
---|---|
img | 输入图像 |
blockSize | |
ksize | |
k |
import numpy as np
import cv2 as cv
filename = 'chessboard.png'
img = cv.imread(filename)
gray = cv.cvtColor(img,cv.COLOR_BGR2GRAY)
gray = np.float32(gray)
dst = cv.cornerHarris(gray,2,3,0.04)
#result is dilated for marking the corners, not important
dst = cv.dilate(dst,None)
# Threshold for an optimal value, it may vary depending on the image.
img[dst>0.01*dst.max()]=[0,0,255]
cv.imshow('dst',img)
if cv.waitKey(0) & 0xff == 27:
cv.destroyAllWindows()
参考文献:
https://blog.csdn.net/qq_41905045/article/details/81973883
https://docs.opencv.org/3.4.3/dc/d0d/tutorial_py_features_harris.html