mirror of
https://github.com/trycua/computer.git
synced 2026-02-24 15:29:01 -06:00
included detection bboxes in label collision check
This commit is contained in:
@@ -112,10 +112,18 @@ class BoxAnnotator:
|
||||
# Keep track of used label areas to check for collisions
|
||||
used_areas = []
|
||||
|
||||
# Store label information for second pass
|
||||
# Store label information for third pass
|
||||
labels_to_draw = []
|
||||
|
||||
# First pass: Draw all bounding boxes
|
||||
# First pass: Initialize used_areas with all bounding boxes
|
||||
for detection in detections:
|
||||
box = detection["bbox"]
|
||||
x1, y1, x2, y2 = [
|
||||
int(coord * dim) for coord, dim in zip(box, [image.width, image.height] * 2)
|
||||
]
|
||||
used_areas.append((x1, y1, x2, y2))
|
||||
|
||||
# Second pass: Draw all bounding boxes
|
||||
for idx, detection in enumerate(detections, 1):
|
||||
# Get box coordinates
|
||||
box = detection["bbox"]
|
||||
@@ -233,7 +241,7 @@ class BoxAnnotator:
|
||||
}
|
||||
)
|
||||
|
||||
# Second pass: Draw all labels on top
|
||||
# Third pass: Draw all labels on top
|
||||
for label_info in labels_to_draw:
|
||||
# Draw background box with white outline
|
||||
draw.rectangle(
|
||||
|
||||
Reference in New Issue
Block a user