def annotate_img()

in src/lambda/notification_function.py [0:0]


def annotate_img(img, labels):
    image = Image.open(io.BytesIO(img))
    draw = ImageDraw.Draw(image)

    labels_to_annotate = {
        'Person': '#0000FF',  # blue
        'Helmet': '#00FF00'   # green
    }

    for label, color in labels_to_annotate.items():
        for p in labels[label]['Instances']:
            bbox = resize_bbox(image, p['BoundingBox'])
            draw_bounding_box(draw, bbox, color)

    buffer = io.BytesIO()
    image.save(buffer, 'JPEG')
    buffer.seek(0)

    return buffer