modèle correspondant à plusieurs boîtes de délimitation sorties en besoin d'un seul besoin

img_rgb = cv2.imread('obsvu.jpg')
img_rgb = cv2.medianBlur(img_rgb, 7)

img_gray = cv2.cvtColor(img_rgb, cv2.COLOR_BGR2GRAY)

template_image = cv2.imread('template.jpg',0)
template_image = cv2.medianBlur(template_image, 5)
width, height = template_image.shape[::-1]

res = cv2.matchTemplate(img_gray, template_image, cv2.TM_CCOEFF_NORMED)

threshold =  0.6

locations = np.where(res >= threshold)

new_locations = group_locations(np.array(locations).T, 50).T

for position_tuple in zip(*new_locations.astype(int)[::-1]):
        cv2.rectangle(img_rgb, position_tuple, (position_tuple[0] + width, position_tuple[1] + height), (0,255,0), 5)
Happy Herring