dschandra commited on
Commit
6259874
·
verified ·
1 Parent(s): 28b8c56

Update utils.py

Browse files
Files changed (1) hide show
  1. utils.py +34 -5
utils.py CHANGED
@@ -72,11 +72,40 @@ def render_annotated_clip(frames, analysis, decision, reason, output_path):
72
  for _ in range(20):
73
  out.write(verdict_card)
74
 
75
- # Dynamic replay
76
- for t, f in enumerate(frames):
77
- annotated = f.copy()
78
- overlay_annotations_dynamic(annotated, analysis, t)
79
- out.write(annotated)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
80
 
81
  # Slow-motion: emphasize final 3 points
82
  for pt in analysis['trajectory_curve'][-3:]:
 
72
  for _ in range(20):
73
  out.write(verdict_card)
74
 
75
+ # Dynamic replay with animated ball tracking
76
+ trajectory_points = analysis.get("trajectory_curve", [])
77
+
78
+ for t, f in enumerate(frames):
79
+ annotated = f.copy()
80
+
81
+ # Draw trajectory arc up to frame t
82
+ for i in range(1, min(t + 1, len(trajectory_points))):
83
+ cv2.line(annotated, trajectory_points[i - 1], trajectory_points[i],
84
+ (0, 255, 0) if analysis['trajectory'] == 'hitting' else (0, 0, 255), 2)
85
+
86
+ # Draw current ball position
87
+ if t < len(trajectory_points):
88
+ ball_pos = trajectory_points[t]
89
+ cv2.circle(annotated, ball_pos, 8,
90
+ (0, 255, 0) if analysis['trajectory'] == 'hitting' else (0, 0, 255), -1)
91
+
92
+ # Draw other overlays
93
+ overlay_text(annotated, "ICC LBW Review • Third-Umpire Analysis", (30, annotated.shape[0] - 30), 0.6, (180, 180, 180))
94
+ overlay_text(annotated, f"Trajectory: {analysis['trajectory'].capitalize()}", (30, 130), 0.8,
95
+ (0, 255, 0) if analysis['trajectory'] == 'hitting' else (0, 0, 255))
96
+
97
+ # Optional stump zone overlay
98
+ if 'stump_zone' in analysis:
99
+ x1, y1 = analysis['stump_zone'][0]
100
+ x2, y2 = analysis['stump_zone'][1]
101
+ overlay = annotated.copy()
102
+ cv2.rectangle(overlay, (x1, y1), (x2, y2), (255, 255, 255), -1)
103
+ alpha = 0.2
104
+ annotated[:] = cv2.addWeighted(overlay, alpha, annotated, 1 - alpha, 0)
105
+ cv2.rectangle(annotated, (x1, y1), (x2, y2), (180, 180, 180), 2)
106
+
107
+ out.write(annotated)
108
+
109
 
110
  # Slow-motion: emphasize final 3 points
111
  for pt in analysis['trajectory_curve'][-3:]: