Spaces:
Sleeping
Sleeping
Update services/overlay_service.py
Browse files- services/overlay_service.py +10 -8
services/overlay_service.py
CHANGED
@@ -2,15 +2,17 @@ import cv2
|
|
2 |
|
3 |
def overlay_boxes(frame, boxes):
|
4 |
for box in boxes:
|
5 |
-
|
6 |
-
label = box
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
8 |
|
9 |
-
# Draw box
|
10 |
cv2.rectangle(frame, (x1, y1), (x2, y2), (0, 255, 0), 2)
|
|
|
|
|
11 |
|
12 |
-
# Draw label
|
13 |
-
text = f"{label} ({confidence:.2f})"
|
14 |
-
cv2.putText(frame, text, (x1, max(y1 - 10, 0)), cv2.FONT_HERSHEY_SIMPLEX,
|
15 |
-
0.5, (255, 0, 0), 2)
|
16 |
return frame
|
|
|
2 |
|
3 |
def overlay_boxes(frame, boxes):
|
4 |
for box in boxes:
|
5 |
+
score = box['score']
|
6 |
+
label = box['label']
|
7 |
+
bbox = box['box'] # x, y, width, height
|
8 |
+
|
9 |
+
x1 = int(bbox['xmin'])
|
10 |
+
y1 = int(bbox['ymin'])
|
11 |
+
x2 = int(bbox['xmax'])
|
12 |
+
y2 = int(bbox['ymax'])
|
13 |
|
|
|
14 |
cv2.rectangle(frame, (x1, y1), (x2, y2), (0, 255, 0), 2)
|
15 |
+
cv2.putText(frame, f"{label}: {score:.2f}", (x1, y1 - 10),
|
16 |
+
cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 0), 2)
|
17 |
|
|
|
|
|
|
|
|
|
18 |
return frame
|