Detection
A pre-trained YOLOv5xu model is the starting point, with additional training so that it identifies only the players and referees within the football court. Without that step a general detector returns the touchline, the bench, and the crowd, and every downstream stage inherits the noise.
The ball, when it is not there
Detection on a small fast object fails intermittently — occlusion, motion blur, a frame where it is simply not visible. Interpolation fills those gaps so the ball has a continuous path rather than a track that vanishes and reappears somewhere else.
Teams and possession
Team assignment works from colour segmentation of the player crops, which is the signal actually present in the frame. A player-and-ball assigner then attributes possession frame by frame.
Getting to real units
Two corrections stand between pixels and metres, and both are needed:
- A camera-movement estimator measures motion between frames, so camera pan is not counted as player movement.
- A perspective transform maps image coordinates onto the pitch plane, because a pixel near the top of the frame covers far more ground than one near the bottom.
With both applied, the speed and distance estimator reports figures in real units rather than pixels.
Two entry points
One path processes a recorded video in batch; the other runs the pipeline in real time.