簡體   English   中英

如何獲得直線上的曲線點?

[英]How do I get a curve point on a line?

我想檢測所有角落並在線上開始,結束點。 我可以檢測起點和終點,但曲線無法檢測。 這是我的代碼

from scipy.ndimage import generic_filter

def lineEnds(P):
    return 255 * ((P[4]==255) and np.sum(P)==510)

 image = cv2.imread("./dataset/test.jpg" , cv2.COLOR_RGB2GRAY)
 result = generic_filter(image , lineEnds, (3, 3))

圖像 = 在此處輸入圖片說明

結果 = 在此處輸入圖片說明

您也可以使用OpenCV檢測角點

import cv2

image = cv2.imread('./test.jpg')
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# Detect corners in the image
corners = cv2.goodFeaturesToTrack(gray, 500, qualityLevel=0.01, minDistance=20)

for c in corners:
    x, y = c.reshape(2)
    print(x, y)
    # draw a circle around the detected corner
    cv2.circle(image, (x, y), radius=4, color=(0, 255, 120), thickness=2)

cv2.imshow("Result", image)
cv2.waitKey(0)

結果:

在此處輸入圖片說明

有關更多詳細信息,請查看這些文檔:

Shi-Tomasi 角檢測器

哈里斯角檢測

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM