Spaces:
Sleeping
Sleeping
Update services/overlay_service.py
Browse files- services/overlay_service.py +6 -17
services/overlay_service.py
CHANGED
|
@@ -1,21 +1,10 @@
|
|
| 1 |
import cv2
|
| 2 |
|
| 3 |
-
def overlay_boxes(
|
| 4 |
-
image
|
| 5 |
-
if image is None:
|
| 6 |
-
return None
|
| 7 |
-
|
| 8 |
for box in boxes:
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
cv2.rectangle(image, (x1, y1), (x2, y2),
|
| 12 |
-
cv2.putText(
|
| 13 |
-
image,
|
| 14 |
-
label,
|
| 15 |
-
(x1, y1 - 10),
|
| 16 |
-
cv2.FONT_HERSHEY_SIMPLEX,
|
| 17 |
-
0.5,
|
| 18 |
-
color,
|
| 19 |
-
2
|
| 20 |
-
)
|
| 21 |
return image
|
|
|
|
| 1 |
import cv2
|
| 2 |
|
| 3 |
+
def overlay_boxes(image, boxes):
|
| 4 |
+
# Directly use the image (NumPy array)
|
|
|
|
|
|
|
|
|
|
| 5 |
for box in boxes:
|
| 6 |
+
x, y, w, h = box
|
| 7 |
+
x1, y1, x2, y2 = int(x), int(y), int(x + w), int(y + h)
|
| 8 |
+
cv2.rectangle(image, (x1, y1), (x2, y2), (0, 255, 0), 2)
|
| 9 |
+
cv2.putText(image, 'Anomaly', (x1, y1 - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.6, (0, 255, 0), 2)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 10 |
return image
|