https://blog.csdn.net/Keep_Trying_Go/article/details/125384144
Shi-Tomasi It's right Harris Improvement of corner detection ;
because Harris The stability and stability of corner detection algorithm K Coefficient related , and K It's an experience value , So it's hard to set its K The best value of .
goodFeaturesToTrack(image, maxCorners, qualityLevel, minDistance, corners=None, mask=None, blockSize=None, useHarrisDetector=None, k=None)
:Image: Input the original image
;maxCorners: The maximum number of corners , The value is 0 Means unlimited
;qualityLevel: Mass of corners ; Less than 1.0 Positive number of , Generally in 0.01-0.1 Between ; Indicates the lowest quality level of acceptable corners . This factor is multiplied by the best corner fraction ( That is, the smaller eigenvalue above ), As the minimum acceptable score ; for example , If the best corner score is 1500 And the mass coefficient is 0.01, Then all mass fractions are less than 15 All corners will be ignored
.minDistance: Minimum Euclidean distance between angles , Ignore points less than this distance
.Corners: Output a vector value of the detected corner
;Mask: Areas of interest
;blockSize: Detect the size of the window
;userHarrisDetector: Whether to use Harris Algorithm , The default value is false, Don't use Harris Algorithm
;K: The default value is 0.04
;
import os
import cv2
import numpy as np
# Read the picture
img=cv2.imread('images/HaLiSi.jpg')
# Zoom in and out
img=cv2.resize(src=img,dsize=(450,450))
# Go to grayscale
gray=cv2.cvtColor(src=img,code=cv2.COLOR_RGB2GRAY)
tomasiCorners=cv2.goodFeaturesToTrack(image=gray,maxCorners=1000,qualityLevel=0.01,minDistance=10)
# Convert to plastic
tomasiCorners=np.int0(tomasiCorners)
# Traverse all corners
for corner in tomasiCorners:
# Get the coordinates of the corner
x,y=corner.ravel()
cv2.circle(img=img,center=(x,y),radius=3,color=(0,255,0),thickness=-1)
# Display images
cv2.imshow('img',img)
cv2.waitKey(0)
cv2.destroyAllWindows()
if __name__ == '__main__':
print('Pycharm')