- Notifications
You must be signed in to change notification settings - Fork0
A project that utilizes deep learning and computer vision for cost-effective football match analysis. By applying YOLO for object detection and auto-homography for field mapping.
License
mserra0/FootballVision
Folders and files
| Name | Name | Last commit message | Last commit date | |
|---|---|---|---|---|
Repository files navigation
The football analytics industry is rapidly growing, with professional teams increasingly relying on data-driven tools to analyze matches, training sessions, and player performance. However, these systems are often expensive and require specialized hardware for data collection, such as wearable devices or advanced camera setups.
This project proposes a cost-effective solution usingdeep learning andcomputer vision to automatically extract match statistics from single-camera video recordings. By leveraging advanced object detection models like YOLO and techniques such as homography, the system eliminates the need for additional sensors while providing a detailed tactical analysis. This approach is scalable and adaptable for a wide range of applications, from professional teams to amateur setups.
- Features
- Installation
- Usage Instructions
- Data and Tools
- Methodology
- Experiments and Results
- Challenges and Limitations
- Future Work
- Contributors
- License
- Object Detection:
- Detects players, referees, and the ball in video frames using YOLO.
- Field Mapping (Homography):
- Maps camera coordinates to a tactical view of the football field.
- Tracking:
- Tracks individual players and the ball throughout the match using ByteTrack.
- Team Classification:
- Identifies team affiliations using K-means clustering on jersey colors.
- Key Metrics:
- Possession percentages for each team.
- Distance covered by players.
- Maximum and average player velocities.
- Field zones most utilized during play.
- Clone the repository:
git clone https://github.com/username/football-analysis.gitcd football-analysis - Install the required dependencies:
pip install -r requirements.txt
To use this repository, please follow the instructions below to download and place the required model files.
You need to download the models from the following link:
For playing with the models and fine-tuning:
- Place the
yolov5xu.pt,yolov5x.pt, andyolov8x.ptfiles in thetrainingfolder.
- Place the
To try the pre-trained model:
- Replace the entire
modelsfolder in this repository with themodelsfolder from the download link.
- Replace the entire
- Download the models from the provided link.
- Place the required
.ptfiles in thetrainingfolder for fine-tuning. - Replace the
modelsfolder to use the pre-trained model.
- Football Players Detection Dataset: Used for player, referee, and ball detection.
- Custom Annotated Dataset: Created to train YOLOv8 for detecting field keypoints.
- Object Detection: YOLOv5 and YOLOv8 by Ultralytics.
- Tracking: ByteTrack for multi-object tracking.
- Analysis Tools: NumPy, OpenCV, and PyTorch.
Object Detection:
- YOLOv5 is used to detect players, referees, and the ball.
- YOLOv8 is fine-tuned to identify key field points such as lines, circles, and goals for homography.
Field Homography:
- A homography matrix is calculated to transform detected objects’ coordinates into a tactical field perspective. This enables spatial analysis of player positions and ball movements.
Tracking:
- ByteTrack assigns unique identifiers to players and the ball across frames, ensuring continuity in tracking even when objects briefly leave the frame.
Team Classification:
- Colors extracted from detected players’ bounding boxes are clustered using K-means to classify team affiliations.
Metric Computation:
- Distances, velocities, and possession statistics are calculated using player trajectories mapped to the homography-transformed field.
- Detection Performance:
- YOLOv5 effectively detected players and referees with high precision but struggled with smaller objects like the ball due to dataset limitations.
- YOLOv8 achieved good results in the less chaotic videos for field keypoint detection but struggled greatly with the fast camera movements.
Steady scenario where the model performed exceptionally well at detecting keypoints.
- Using these points, we attempted to organize and predict their exact coordinates. However, this effort was unsuccessful due to insufficient information about their relative positions. To address this, we decided to use fixed top-down perspectives of the field, providing a consistent reference for arranging the points systematically
Tracking and Classification:
- ByteTrack maintained robust tracking even during occlusions.
- K-means successfully classified players into teams based on jersey colours.
Generated Metrics:
- Distances covered, velocities, and possession statistics were calculated for individual players and teams. These metrics were validated against manual annotations.
Challenges:
- Frequent camera perspective changes posed significant challenges for maintaining consistent homography.
- Limited ball detection accuracy impacted possession metrics.
Results:
- The final result is presented using footage from the training camera instead of the broadcast television feed. This decision was made because the rapid camera movements in the televised footage prevented accurate homography calculations.
Detection and mapping of players' positions on the field, with calculated team possession percentages.
- Ball Detection: Small object size and motion blur reduced detection accuracy.
- Homography: Camera angle variability required manual adjustments in some cases.
- Limited Dataset: The dataset lacked sufficient diversity for generalization to all match scenarios.
Improved Ball Detection:
- Use a larger and more diverse dataset to enhance YOLO’s performance on small, fast-moving objects.
Automated Homography:
- Train models specialized in pose estimation to provide more robust and automated field mapping.
Key points for pose estimation.
Expanded Metrics:
- Include tactical insights such as formations, pass networks, and heatmaps.
Real-Time Processing:
- Optimize the pipeline to enable real-time analysis during live matches.
- Marc Serra Ortega
- Pol Pugibet Martínez
This project is licensed under theMIT License.
About
A project that utilizes deep learning and computer vision for cost-effective football match analysis. By applying YOLO for object detection and auto-homography for field mapping.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.




