Spaces:
Sleeping
Sleeping
Update utils.py
Browse files
utils.py
CHANGED
@@ -93,3 +93,25 @@ def render_annotated_clip(frames, analysis, decision, reason, output_path):
|
|
93 |
out.write(verdict_card)
|
94 |
|
95 |
out.release()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
93 |
out.write(verdict_card)
|
94 |
|
95 |
out.release()
|
96 |
+
|
97 |
+
def overlay_dynamic_tracking(frames, output_path):
|
98 |
+
trajectory_points = [(200 + i * 10, 300 - i * 7) for i in range(min(len(frames), 6))]
|
99 |
+
h, w = frames[0].shape[:2]
|
100 |
+
out = cv2.VideoWriter(output_path, cv2.VideoWriter_fourcc(*'mp4v'), 20.0, (w, h))
|
101 |
+
|
102 |
+
for i, frame in enumerate(frames):
|
103 |
+
annotated = frame.copy()
|
104 |
+
# Draw previous path
|
105 |
+
for j in range(1, min(i+1, len(trajectory_points))):
|
106 |
+
cv2.line(annotated, trajectory_points[j-1], trajectory_points[j], (0, 255, 0), 2)
|
107 |
+
# Draw ball
|
108 |
+
if i < len(trajectory_points):
|
109 |
+
cv2.circle(annotated, trajectory_points[i], 8, (0, 255, 0), -1)
|
110 |
+
# Optional: Stump zone or labels
|
111 |
+
cv2.putText(annotated, "Ball Tracking Simulation", (30, 40),
|
112 |
+
cv2.FONT_HERSHEY_SIMPLEX, 1.0, (255,255,255), 2)
|
113 |
+
out.write(annotated)
|
114 |
+
|
115 |
+
out.release()
|
116 |
+
return output_path
|
117 |
+
|