Spaces:
Runtime error
Runtime error
Update services/overlay_service.py
Browse files
services/overlay_service.py
CHANGED
@@ -1,7 +1,11 @@
|
|
1 |
import cv2
|
2 |
|
3 |
-
def overlay_boxes(frame,
|
4 |
-
for
|
|
|
|
|
5 |
x_min, y_min, x_max, y_max = map(int, box)
|
6 |
-
|
7 |
-
|
|
|
|
|
|
1 |
import cv2
|
2 |
|
3 |
+
def overlay_boxes(frame, cracks):
|
4 |
+
for crack in cracks:
|
5 |
+
box = crack['box']
|
6 |
+
severity = crack['severity']
|
7 |
x_min, y_min, x_max, y_max = map(int, box)
|
8 |
+
color = (0, 0, 255) if severity == 'Severe' else (0, 255, 255) if severity == 'Moderate' else (0, 255, 0)
|
9 |
+
cv2.rectangle(frame, (x_min, y_min), (x_max, y_max), color, 2)
|
10 |
+
cv2.putText(frame, severity, (x_min, y_min - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, color, 2)
|
11 |
+
return frame
|