import cv2 import numpy as np def draw_boxes(frame, detections, class_names): for x1, y1, x2, y2, conf, cls_id in detections: label = class_names[int(cls_id)] color = (0, 255, 0) if label == 'ball' else (255, 0, 0) cv2.rectangle(frame, (int(x1), int(y1)), (int(x2), int(y2)), color, 2) cv2.putText(frame, f"{label} {conf:.2f}", (int(x1), int(y1) - 5), cv2.FONT_HERSHEY_SIMPLEX, 0.6, color, 2) return frame def overlay_decision_text(frame, decision): font = cv2.FONT_HERSHEY_SIMPLEX text = f"Decision: {decision}" text_size = cv2.getTextSize(text, font, 1.0, 2)[0] text_x = (frame.shape[1] - text_size[0]) // 2 text_y = 50 cv2.putText(frame, text, (text_x, text_y), font, 1.0, (0, 255, 255), 2, cv2.LINE_AA) return frame