File size: 830 Bytes
3d1a9bc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from PIL import ImageDraw

def draw_bounding_boxes(image, boxes, model, conf_threshold):
    """
    Draw bounding boxes on the image.

    Args:
        image (PIL.Image): The input image.
        boxes (list): List of bounding boxes with confidence scores.
        model: The object detection model (not used in this basic implementation).
        conf_threshold (float): Confidence threshold for filtering boxes.

    Returns:
        PIL.Image: The image with bounding boxes drawn.
    """
    draw = ImageDraw.Draw(image)
    for box in boxes:
        if box["score"] >= conf_threshold:
            x_min, y_min, x_max, y_max = box["box"]
            draw.rectangle([x_min, y_min, x_max, y_max], outline="red", width=3)
            draw.text((x_min, y_min), f"{box['label']} {box['score']:.2f}", fill="red")
    return image