This project focuses on using computer vision techniques to analyse football matches. By utilising YOLO (You Only Look Once) for object detection and OpenCV for image processing, the project can track and analyse football players' movements and key moments during a match. This analysis can provide insights into player positioning, team strategies, and game patterns.
- Player Detection: Detect football players in video footage using YOLO's real-time object detection capabilities.
- Movement Tracking: Track player movement across the pitch using OpenCV for video frame analysis.
- Zone Heatmap: Generate heatmaps to visualise which zones players spend the most time in.
- Key Moment Detection: Identify key moments such as goals, fouls, and possession changes through visual cues and manual tagging.
- Performance Metrics: Extract metrics like distance covered, speed, and player proximity during a match.
-
Clone the repository:
git clone https://github.com/username/football-analysis-cv.git cd football-analysis-cv -
Set up a virtual environment (optional but recommended):
python3 -m venv venv source venv/bin/activate # On Windows, use `venv\Scripts�ctivate`
-
Install the required dependencies:
pip install -r requirements.txt
-
Download the pretrained YOLO model weights from the YOLO website and place them in the
model/directory. -
To analyse a video, run the following command:
python analyse_video.py --input <path_to_video> --output <output_directory>
For example:
python analyse_video.py --input videos/match.mp4 --output results/
-
The output will include a summary of key metrics, heatmaps, and annotated video frames saved in the output directory.
analyse_video.py: Main script to analyse video footage of football matches.models/: Directory containing the YOLO model weights and configuration files.utils/: Utility functions for video processing, heatmap generation, and metric calculation.videos/: Sample football match videos (not included in the repo).results/: Generated analysis results such as heatmaps and processed videos.
- Python 3.7+
- OpenCV
- YOLO (You Only Look Once) model
- NumPy
- Matplotlib
To install dependencies:
pip install -r requirements.txt- Real-time Analysis: Implement live match analysis from real-time video streams.
- Tactics Recognition: Detect and analyse team formations and tactics using more advanced models.
- Enhanced Key Moment Detection: Automate the detection of more complex events like offside, penalties, and set-pieces.
Contributions are welcome! If you have suggestions for improvement or would like to report a bug, feel free to open an issue or submit a pull request.
- View a sample output video here: https://drive.google.com/file/d/1n-EUl6D-aBWeVOVGCN7Mlnzqpz4Bxife/view?usp=sharing