def create_filled_polygon_mask()

in src/co_op_translator/utils/vision/image_utils.py [0:0]


def create_filled_polygon_mask(bounding_box, image_size, fill_color):
    """
    Create a filled polygon mask for the bounding box area.

    Args:
        bounding_box (list): The bounding box coordinates.
        image_size (tuple): The size of the image (width, height).
        fill_color (tuple): The fill color (R, G, B, A).

    Returns:
        PIL.Image.Image: The mask image.
    """
    mask_image = Image.new("RGBA", image_size, (255, 255, 255, 0))
    mask_draw = ImageDraw.Draw(mask_image)
    pts = [
        (bounding_box[i], bounding_box[i + 1]) for i in range(0, len(bounding_box), 2)
    ]
    mask_draw.polygon(pts, fill=fill_color)
    return mask_image