Я пытаюсь выяснить Hough Circles, прежде чем включить его в свой основной код для программы отслеживания, которую я пытаюсь написать, но я не могу ничего получить, кроме None
. круги. Я использую флаг Бенгали в качестве своего изображения, поскольку он прост и будет легко обнаружить. Вот мой код:Python OpenCV Hough Circles возвращает None
import numpy as np
import cv2
img = cv2.imread('Capture.PNG')
grayput = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
circles = cv2.HoughCircles(grayput, cv2.cv.CV_HOUGH_GRADIENT, 1, 20, param1 =50, param2 =10, minRadius=10, maxRadius=40)
print (circles)
# need circles
if circles is not None:
# convert the coord. to integers
circles = np.round(circles[0, :]).astype("int")
# loop over the (x, y) coordinates and radius of the circles
for (x, y, r) in circles:
# draw the circle in the output image
cv2.circle(img, (x, y), r, (0, 0, 0), 4)
cv2.imwrite("image.PNG",img)