Football Analysis
Overview
This project analyses football matches using advanced computer vision techniques, including:
- YOLO for object detection (players, ball, referees).
- ByteTrack for tracking movements.
- KMeans and SigLip for team classification.
Key Components
1. Input and Output Processing
- OpenCV is utilized for:
- Extracting frames from video inputs.
- Applying visualizations on the processed frames.
- Saving the processed frames back into video format.
2. Object Detection and Tracking
- YOLOv11n is used for object detection.YOLO
- ByteTrack is utilized for tracking players, ball, and referees. ByteTrack
- The initial dataset used was provided by Bundesliga on Kaggle. It is now available on Roboflow.
3. Team Classification
Workflow:
-
Player Cropping:
- Player crops are extracted from video frames using YOLO detection boxes.
-
Background and Torso Clustering:
- KMeans is applied to separate the background from player torsos.
| | |
| Before Clustering | After Clustering Background and Torso |
- Team Color Classification:
- The colors of players' shirts are clustered to distinguish between two teams.
How to Run
- Install dependencies:
pip install -r requirements.txt
- Download required models from the
models/
directory. - Execute the script:
python main.py -i {input_video_path} -o {output_path} -r {results_path}
- Outputs:
- Results are saved as parquet files.
- Processed frames and videos are stored in the specified output path.
Upcoming Features
- Radar View:
- Using
mplsoccer
to create a radar view for tactical analysis.
- Using
| | |
- Enhanced Statistics:
- Calculating player metrics such as:
- Movement speed.
- Passing accuracy and types of passes.
- Generating heatmaps and advanced visualizations for deeper insights.
- Calculating player metrics such as: