我使用下面的算法(cornerHarris)檢測了此圖像的角點(圖像中的紅點)。現在我想獲得該點的座標。我怎樣才能做到這一點?如何使用python獲取x,y座標?
import cv2
import numpy as np
filename = 'Square.jpg'
img = cv2.imread(filename)
gray = cv2.cvtColor(img,cv2.COLOR_BGR2GRAY)
gray = np.float32(gray)
dst = cv2.cornerHarris(gray,2,3,0.04)
#result is dilated for marking the corners, not important
dst = cv2.dilate(dst,None)
# Threshold for an optimal value, it may vary depending on the image.
img[dst>0.01*dst.max()]=[0,0,255]
cv2.imshow('dst',img)
cv2.waitKey(0)
cv2.imwrite('CornerSquare.jpg',img)
我不是太熟悉Python或哈里斯來者,但通過掃描你的代碼,我沒有看到,是指任何代碼,您已經檢測到的紅點 –
驗證碼工作中!而我上傳的圖片就是我通過運行它所得到的。 –