程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
您现在的位置: 程式師世界 >> 編程語言 >  >> 更多編程語言 >> Python

Shi Tomasi corner detection (implemented in Python)

編輯:Python

List of articles

    • 1.Harris feature detection
    • 2.Shi-Tomasi Corner detection
    • 3.Shi-Tomasi Explanation of corner detection function
    • 4. Code combat

1.Harris feature detection

https://blog.csdn.net/Keep_Trying_Go/article/details/125384144


2.Shi-Tomasi Corner detection

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 .


3.Shi-Tomasi Explanation of corner detection function

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;


4. Code combat

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')


  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式師世界 All Rights Reserved