Spaces:
Sleeping
Sleeping
Update gully_drs_core/replay_utils.py
Browse files
gully_drs_core/replay_utils.py
CHANGED
@@ -1,12 +1,23 @@
|
|
1 |
# gully_drs_core/replay_utils.py
|
|
|
2 |
import cv2
|
3 |
|
4 |
-
def generate_replay(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
|
6 |
height, width = frames[0].shape[:2]
|
7 |
out = cv2.VideoWriter(output_path, fourcc, fps, (width, height))
|
8 |
|
9 |
for i, frame in enumerate(frames):
|
|
|
10 |
if i < len(ball_path):
|
11 |
for j in range(1, i):
|
12 |
if j < len(ball_path):
|
@@ -17,19 +28,29 @@ def generate_replay(frames, ball_path, bounce_point, impact_point, decision, stu
|
|
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),
|
|
|
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),
|
|
|
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(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
|
34 |
out.write(frame)
|
35 |
|
|
|
1 |
# gully_drs_core/replay_utils.py
|
2 |
+
|
3 |
import cv2
|
4 |
|
5 |
+
def generate_replay(
|
6 |
+
frames,
|
7 |
+
ball_path,
|
8 |
+
bounce_point,
|
9 |
+
impact_point,
|
10 |
+
decision,
|
11 |
+
stump_zone,
|
12 |
+
output_path='output.mp4',
|
13 |
+
fps=30
|
14 |
+
):
|
15 |
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
|
16 |
height, width = frames[0].shape[:2]
|
17 |
out = cv2.VideoWriter(output_path, fourcc, fps, (width, height))
|
18 |
|
19 |
for i, frame in enumerate(frames):
|
20 |
+
# Draw ball trajectory
|
21 |
if i < len(ball_path):
|
22 |
for j in range(1, i):
|
23 |
if j < len(ball_path):
|
|
|
28 |
# Draw bounce point
|
29 |
if bounce_point:
|
30 |
cv2.circle(frame, bounce_point, 8, (255, 255, 0), -1)
|
31 |
+
cv2.putText(frame, "Bounce", (bounce_point[0]+5, bounce_point[1]-10),
|
32 |
+
cv2.FONT_HERSHEY_SIMPLEX, 0.5, (255, 255, 0), 1)
|
33 |
|
34 |
# Draw impact point
|
35 |
if impact_point:
|
36 |
cv2.circle(frame, impact_point, 8, (0, 255, 255), -1)
|
37 |
+
cv2.putText(frame, "Impact", (impact_point[0]+5, impact_point[1]-10),
|
38 |
+
cv2.FONT_HERSHEY_SIMPLEX, 0.5, (0, 255, 255), 1)
|
39 |
|
40 |
# Draw stump zone
|
41 |
x1, y1, x2, y2 = stump_zone
|
42 |
cv2.rectangle(frame, (x1, y1), (x2, y2), (255, 0, 0), 2)
|
43 |
|
44 |
# Show decision at top
|
45 |
+
cv2.putText(
|
46 |
+
frame,
|
47 |
+
f"Decision: {decision}",
|
48 |
+
(20, 40),
|
49 |
+
cv2.FONT_HERSHEY_SIMPLEX,
|
50 |
+
1,
|
51 |
+
(0, 255, 0) if decision == "NOT OUT" else (0, 0, 255),
|
52 |
+
2
|
53 |
+
)
|
54 |
|
55 |
out.write(frame)
|
56 |
|