1. 程式人生 > 程式設計 >python opencv角點檢測連線功能的實現程式碼

python opencv角點檢測連線功能的實現程式碼

原始圖

在這裡插入圖片描述

角點檢測

points = cv2.goodFeaturesToTrack(gray,100,0.01,10)
points = np.int0(points).reshape(-1,2)

for point in points:
  x,y = point.ravel()
  cv2.circle(img,(x,y),10,(0,255,0),-1)

在這裡插入圖片描述

連線

cv2.line(img,y1),(1000,thickness=3,lineType=8)
cv2.line(img,y2),lineType=8)

在這裡插入圖片描述

完整程式碼

""" 
@author: qq群686070107
""" 
import cv2
import numpy as np
img=cv2.imread("1.jpg")
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
points = cv2.goodFeaturesToTrack(gray,-1)


y1 = min(points[:,1])
y2 = max(points[:,1])

## small and big enough 
cv2.line(img,lineType=8)

cv2.imshow("img",img)
cv2.waitKey(0)

到此這篇關於python opencv角點檢測 連線功能的實現程式碼的文章就介紹到這了,更多相關python opencv角點檢測內容請搜尋我們以前的文章或繼續瀏覽下面的相關文章希望大家以後多多支援我們!