Я пытаюсь обнаружить круги на плоской поверхности, например, на хоккейной площадке. Однако они не обнаруживаются, и обнаруживается случайный круг.
![enter image description here](https://i.stack.imgur.com/Kttiq.jpg)
Используемый код:
import cv2
import numpy as np
# Read image as gray-scale
img = cv2.imread("frame5.jpg", _path, cv2.IMREAD_COLOR)
bilateral_filtered_image = cv2.bilateralFilter(img, 5, 175, 175)
cv2.imshow('Bilateral', bilateral_filtered_image)
cv2.waitKey(0)
edge_detected_image = cv2.Canny(bilateral_filtered_image, 75, 200)
cv2.imshow('Edge', edge_detected_image)
cv2.waitKey(0)
contours, hierarchy = cv2.findContours(edge_detected_image, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
contour_list = []
for contour in contours:
approx = cv2.approxPolyDP(contour,0.01*cv2.arcLength(contour,True),True)
area = cv2.contourArea(contour)
if ((len(approx) > 8) & (len(approx) < 23) & (area > 30) ):
contour_list.append(contour)
cv2.drawContours(img, contour_list, -1, (255,0,0), 2)
cv2.imshow('Objects Detected',img)
cv2.waitKey(0)
Однако выходЯ получаю что-то вроде этого:
![enter image description here](https://i.stack.imgur.com/d5p5C.png)
Примечание. Чтобы запустить приведенный выше код, входное изображение необходимо сохранить как «frame5.jpg» врабочий каталог.