Estoy tratando de detectar los agujeros dejados en una silueta de tiro usan HoughCircle. He intentado ajustar los parámetros pero no consigo detectar del todo bien.
Esta es aplicando los algoritmos:
Mi código es el siguiente:
import numpy as np
import cv2
im = cv2.imread('silhouette.jpg')
imgray = cv2.cvtColor(im,cv2.COLOR_BGR2GRAY)
ret0,thresh0 = cv2.threshold(imgray,180,200,cv2.THRESH_TRUNC)
ret,thresh = cv2.threshold(thresh0,40,255,cv2.THRESH_BINARY)
kernel = np.ones((2, 2), np.uint8)
mask = cv2.erode(thresh, kernel, iterations=2)
mask = cv2.GaussianBlur(mask,(7,7),0)
circles = cv2.HoughCircles(mask,cv2.HOUGH_GRADIENT,2,6,
param1=50,param2=8,minRadius=1,maxRadius=13)
imgray = cv2.cvtColor(imgray, cv2.COLOR_GRAY2BGR)
if circles is not None:
circles = np.uint16(np.around(circles))
for i in circles[0,:]:
cv2.circle(imgray,(i[0],i[1]),i[2],(0,255,0),2)
# draw the center imof the circle
cv2.circle(imgray,(i[0],i[1]),2,(0,0,255),2)
cv2.imshow('detecion', imgray)
cv2.waitKey(0)
cv2.destroyAllWindows()
Alguna idea para mejorar la detección de los agujeros?