Spaces:
Runtime error
Runtime error
import cv2 | |
def overlay_boxes(frame, cracks): | |
for crack in cracks: | |
box = crack['box'] | |
severity = crack['severity'] | |
x_min, y_min, x_max, y_max = map(int, box) | |
color = (0, 0, 255) if severity == 'Severe' else (0, 255, 255) if severity == 'Moderate' else (0, 255, 0) | |
cv2.rectangle(frame, (x_min, y_min), (x_max, y_max), color, 2) | |
cv2.putText(frame, severity, (x_min, y_min - 10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, color, 2) | |
return frame |