Я написал небольшую функцию в python, которая должна обнаруживать круги в кадре камеры моего raspberry pi. Но я получил эту ошибку и не знаю почему?
Traceback (most recent call last):
File "main.py", line 200, in <module>
rescue()
File "main.py", line 124, in rescue
for (x, y, r) in circles:
TypeError: 'NoneType' object is not iterable
это функция спасения:
def rescue():
cv2. destroyAllWindows()
global rescue
rescue = True
while rescue:
# load the image, clone it for output, and then convert it to grayscale
image = frame.array
output = image
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
# detect circles in the image
circles = cv2.HoughCircles(gray, cv2.HOUGH_GRADIENT, 1.55, 300)
# ensure at least some circles were found
if circles is not None:
# convert the (x, y) coordinates and radius of the circles 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:
cv2.circle(image, (x, y), r, (255, 255, 0), 4)
cv2.rectangle(image, (x - 5, y - 5), (x + 5, y + 5), (0, 0, 255), -1)
print(str((x-160)).encode()) #output values
cv2.imshow("output", image)
key = cv2.waitKey(1) & 0xFF
rawCapture.truncate(0)
Заранее спасибо