我是opencv的新手,我正尝试使用HoughCircles进行圆检测,但是它给了我没有圆的圆,也没有检测到我想要的巨大圆。我尝试更改参数,但无法使其正常运行。我在做什么错了?
path=r"minimap.png"
screen = cv2.imread(path,cv2.IMREAD_GRAYSCALE)
cv2.imshow('Original', screen)
ret,screen = cv2.threshold(screen,200,255,cv2.THRESH_BINARY)
cv2.imshow('Thresholded', screen)
P=50
can = cv2.Canny(screen,P/2,P)
cv2.imshow('Canny', can)
if 1:
circles = cv2.HoughCircles(screen, cv2.HOUGH_GRADIENT, dp=1, minDist=50, param1=P, param2=53, minRadius=0, maxRadius=0)
print(circles)
circles = np.uint16(np.around(circles))
can=cv2.cvtColor(can,cv2.COLOR_GRAY2RGB)
for i in circles[0,:]:
# draw the outer circle
cv2.circle(can, (i[0], i[1]), i[2], (0, 255, 0), 3)
# draw the center of the circle
cv2.circle(can, (i[0], i[1]), 2, (0, 0, 255), 5)
cv2.imshow('Circles', can)
cv2.waitKey()