Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR TYPESCRIPT

template matching several bounding boxes outputted need only one

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)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #template #matching #bounding #boxes #outputted
ADD COMMENT
Topic
Name
8+5 =