[Python] How can I predict the future landing position of a ball detected with YOLO?

Discussão em 'Python' iniciado por Stack, Agosto 15, 2025.

  1. Stack

    Stack Membro Participativo

    I have a YOLO model that detects a baseball in a video game. For each frame, I can get the (x, y) coordinates of the ball. I want to predict the future position where the ball will cross the plate based on the first few detected positions.

    What I have:


    • A YOLO model that outputs positions for each frame.


    • Sample CSV data with positions:

    frame,x,y
    1,391,91
    2,377,94
    3,380,87
    4,381,86
    5,382,86
    6,382,86
    7,384,85
    8,386,84
    9,511,215


    What I tried:


    • Used an LSTM model with Keras and StandardScaler from scikit-learn.


    • The model predicts almost the same landing spot for every pitch, so it doesn’t work.

    Problem:
    I don’t know whether I should continue with a machine learning approach or switch to a physics-based approach (e.g., fitting a curve to the early positions). I want a reliable way to predict the ball’s future landing position from the first few frames.

    Goal:
    Given the first N frames of ball position data, predict the (x, y) coordinates where the ball will land.

    Additional info:


    Question:


    • Should I use ML (like LSTM or regression) or physics-based trajectory prediction?


    • Can someone provide an example approach to predict the landing point from early frames?

    Continue reading...

Compartilhe esta Página