INNER CODE UNIT · Python
fill_lost_tracking
chonyy/ML-auto-baseball-pitching-overlay · src/utils.py:27
def fill_lost_tracking(frame_list):
balls_x = [frame.ball[0] for frame in frame_list if frame.ball_in_frame]
balls_y = [frame.ball[1] for frame in frame_list if frame.ball_in_frame]
# print(balls_x)
# print(balls_y)
# Get the polynomial equation
curve = np.polyfit(balls_x, balls_y, 2)
poly = np.poly1d(curve)
lost_sections = []
in_lost = False
frame_count = 0
# Get the sections where the ball is lost tracked
for idx, frame in enumerate(frame_list):
if frame.ball_lost_tracking and frame_count == 0: