def get_text_with_location(boxed_image, contours, img):
image_text_dict = {}
for contour in contours:
# get rectangle bounding contour
[x, y, w, h] = cv2.boundingRect(contour)
# draw rectangle around contour on original image
if w < 20 or h < 20:
continue
cv2.rectangle(boxed_image, (x, y), (x + w + 10, y + h + 10), thickness=2, color=0)
box_read = extract_image_from_location(img, x, y, w, h)
box_read = box_read.strip()
image_text_dict[(x, y)] = box_read
return image_text_dict
评论列表
文章目录