Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -26,7 +26,7 @@ if ball_class_index is None:
|
|
| 26 |
STUMPS_WIDTH = 0.2286
|
| 27 |
BALL_DIAMETER = 0.073
|
| 28 |
FRAME_RATE = 20
|
| 29 |
-
SLOW_MOTION_FACTOR =
|
| 30 |
CONF_THRESHOLD = 0.2
|
| 31 |
IMPACT_ZONE_Y = 0.85
|
| 32 |
IMPACT_DELTA_Y = 50
|
|
@@ -72,25 +72,10 @@ def process_video(video_path):
|
|
| 72 |
return frames, ball_positions, detection_frames, "\n".join(debug_log)
|
| 73 |
|
| 74 |
def find_bounce_point(ball_coords):
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
y_coords = [p[1] for p in ball_coords]
|
| 80 |
-
min_index = None
|
| 81 |
-
|
| 82 |
-
for i in range(2, len(y_coords) - 2):
|
| 83 |
-
dy1 = y_coords[i] - y_coords[i - 1]
|
| 84 |
-
dy2 = y_coords[i + 1] - y_coords[i]
|
| 85 |
-
if dy1 > 0 and dy2 < 0:
|
| 86 |
-
if i > len(y_coords) * 0.2:
|
| 87 |
-
min_index = i
|
| 88 |
-
break
|
| 89 |
-
|
| 90 |
-
if min_index is not None:
|
| 91 |
-
return ball_coords[min_index]
|
| 92 |
-
|
| 93 |
-
return ball_coords[len(ball_coords)//2]
|
| 94 |
|
| 95 |
def lbw_decision(ball_positions, trajectory, frames, pitch_point, impact_point):
|
| 96 |
if not frames or not trajectory or len(ball_positions) < 2:
|
|
@@ -207,4 +192,4 @@ iface = gr.Interface(
|
|
| 207 |
)
|
| 208 |
|
| 209 |
if __name__ == "__main__":
|
| 210 |
-
iface.launch()
|
|
|
|
| 26 |
STUMPS_WIDTH = 0.2286
|
| 27 |
BALL_DIAMETER = 0.073
|
| 28 |
FRAME_RATE = 20
|
| 29 |
+
SLOW_MOTION_FACTOR = 3
|
| 30 |
CONF_THRESHOLD = 0.2
|
| 31 |
IMPACT_ZONE_Y = 0.85
|
| 32 |
IMPACT_DELTA_Y = 50
|
|
|
|
| 72 |
return frames, ball_positions, detection_frames, "\n".join(debug_log)
|
| 73 |
|
| 74 |
def find_bounce_point(ball_coords):
|
| 75 |
+
for i in range(1, len(ball_coords) - 1):
|
| 76 |
+
if ball_coords[i-1][1] < ball_coords[i][1] > ball_coords[i+1][1]:
|
| 77 |
+
return ball_coords[i]
|
| 78 |
+
return ball_coords[len(ball_coords)//3] # fallback
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 79 |
|
| 80 |
def lbw_decision(ball_positions, trajectory, frames, pitch_point, impact_point):
|
| 81 |
if not frames or not trajectory or len(ball_positions) < 2:
|
|
|
|
| 192 |
)
|
| 193 |
|
| 194 |
if __name__ == "__main__":
|
| 195 |
+
iface.launch()
|