def draw_bounding_boxes(celeb_objs, file):
'''
Draws bounding boxes around all faces in inputted file determined by celeb_objs
'''
colors = []
im = Image.open(file)
draw = ImageDraw.Draw(im)
for i in range(len(celeb_objs)):
color = rectangle_colors[i % len(rectangle_colors)]
colors.append(color)
coords = get_coords_from_ratios(celeb_objs[i].to_dict()['BoundingBox'], im.width, im.height)
draw_width_rectangle(draw, coords, color, rectangle_width)
del draw
file.seek(0)
im.save(file, 'PNG')
return colors
评论列表
文章目录