AjaykumarPilla commited on
Commit
3d9dfef
·
verified ·
1 Parent(s): 4574aff

Update gully_drs_core/replay_utils.py

Browse files
Files changed (1) hide show
  1. gully_drs_core/replay_utils.py +19 -3
gully_drs_core/replay_utils.py CHANGED
@@ -1,9 +1,7 @@
1
  # gully_drs_core/replay_utils.py
2
  import cv2
3
- import numpy as np
4
- import os
5
 
6
- def generate_replay(frames, ball_path, output_path='output.mp4', fps=30):
7
  fourcc = cv2.VideoWriter_fourcc(*'mp4v')
8
  height, width = frames[0].shape[:2]
9
  out = cv2.VideoWriter(output_path, fourcc, fps, (width, height))
@@ -15,6 +13,24 @@ def generate_replay(frames, ball_path, output_path='output.mp4', fps=30):
15
  pt1 = ball_path[j-1]
16
  pt2 = ball_path[j]
17
  cv2.line(frame, pt1, pt2, (0, 0, 255), 2)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
  out.write(frame)
19
 
20
  out.release()
 
1
  # gully_drs_core/replay_utils.py
2
  import cv2
 
 
3
 
4
+ def generate_replay(frames, ball_path, bounce_point, impact_point, decision, stump_zone, output_path='output.mp4', fps=30):
5
  fourcc = cv2.VideoWriter_fourcc(*'mp4v')
6
  height, width = frames[0].shape[:2]
7
  out = cv2.VideoWriter(output_path, fourcc, fps, (width, height))
 
13
  pt1 = ball_path[j-1]
14
  pt2 = ball_path[j]
15
  cv2.line(frame, pt1, pt2, (0, 0, 255), 2)
16
+
17
+ # Draw bounce point
18
+ if bounce_point:
19
+ cv2.circle(frame, bounce_point, 8, (255, 255, 0), -1)
20
+ cv2.putText(frame, "Bounce", (bounce_point[0]+5, bounce_point[1]-10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255,255,0), 1)
21
+
22
+ # Draw impact point
23
+ if impact_point:
24
+ cv2.circle(frame, impact_point, 8, (0, 255, 255), -1)
25
+ cv2.putText(frame, "Impact", (impact_point[0]+5, impact_point[1]-10), cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0,255,255), 1)
26
+
27
+ # Draw stump zone
28
+ x1, y1, x2, y2 = stump_zone
29
+ cv2.rectangle(frame, (x1, y1), (x2, y2), (255, 0, 0), 2)
30
+
31
+ # Show decision at top
32
+ cv2.putText(frame, f"Decision: {decision}", (20, 40), cv2.FONT_HERSHEY_SIMPLEX, 1, (0,255,0) if decision=="NOT OUT" else (0,0,255), 2)
33
+
34
  out.write(frame)
35
 
36
  out.release()