This repository is a computer vision project for football analytics, designed to provide detailed insights into the game through advanced video analysis. It is a fork of roboflow/sports, which offers foundational functionality and examples for training models.
Declaration: All models in this repository have been retrained to achieve improved accuracy compared to the original repository.
This project follows a step-by-step implementation based on the tutorial: Football Analytics with YOLOv8 and ByteTrack. Below is an overview of the workflow and features:
-
Object Detection:
- YOLOv8 is used to detect four classes:
player
,goalkeeper
,referee
, andfootball
.
- YOLOv8 is used to detect four classes:
-
Player and Object Tracking:
- ByteTrack tracks
players
,goalkeepers
, andreferees
.
- ByteTrack tracks
-
Field Keypoint Detection:
- YOLOv8-pose detects the keypoints of the football field.
-
Team Classification:
- Uses K-means clustering with SigLip output as the feature for classifying players into teams based on their jersey colors.
-
Bird-Eye View (BEV) Transformation:
- Perspective projection transforms camera frames into a top-down BEV for better spatial analysis.
- Issue: The original training parameters for keypoint detection produced inconsistent results.
- Solution: Enhanced data augmentation techniques, such as:
- Random perspective transformations.
- Random rotations.
- Increased random cropping.
- Additional training epochs.
- Result: Improved model stability, which is critical for accurate perspective transformation to BEV.
- Issue: ByteTrack often struggled with occlusions, causing ID switches.
- Solution: Replaced ByteTrack with DeepSORT and used SigLip as the feature extractor.
- Result: The feature-based tracker performed significantly better during player occlusions, as players from different teams usually have distinct jersey colors.
- Issue: Initially, the feature extractor cropped the entire bounding box (bbox) around a player, leading to noisy background information.
- Solution: Shrinking the bbox during cropping reduced background noise.
- Result: Improved team classification and better tracking performance.
- Issue: Using the ball's current position in the camera frame for perspective transformation often caused inaccuracies, especially when the ball was in the air.
- Solution: Refined the ball trajectory using cues from changes in direction and velocity.
- Result: Accurate BEV projection, even when the ball was airborne, as demonstrated in the video.
This project is built on the foundational work of the roboflow/sports repository and leverages the techniques explained in the YouTube tutorial. Special thanks to the creators for their contributions to sports analytics.
Feel free to explore, contribute, or use this project to enhance football analytics workflows!
We don't have a Python package yet. Install from source in a Python>=3.8 environment.
pip install git+https://github.com/roboflow/sports.git
use case | dataset |
---|---|
soccer player detection | |
soccer ball detection | |
soccer pitch keypoint detection |
Visit Roboflow Universe and explore other sport-related datasets.
football_analytics_2e57b9.mp4
We love your input! Let us know what else we should build!