Automated football match analysis using Computer Vision.
Explore the docs »
Report Bug
·
Request Feature
The project called MatchVision allows tracking the ball, referees and players, treating players individually by ID and assigning them to a team, displaying ball possession and estimating the camera movement.
Training
The model was trained on Google Colab's servers with T4 GPU (~ 45 mins.)
It uses a custom trained YOLOv5 model.
Benefits:
- better ball tracking
- not tracking persons outside the pitch
Structure
The YOLO model detects the bounding boxes of the objects. They get stored in a dictionary along with the tracking ID, the team ID, the position etc.
The team detection is based on KMeans clustering.
To improve the ball highlighting, the ball position gets interpolated with Pandas.
The camera movement gets estimated with optical flow to adjust the object positions.
Input Video Example
Result
The source code was built with Python, mainly using Ultralytics, OpenCV and NumPy.
Requirements can be found under requirements.txt
.
pip install -r requirements.txt
Warning: Run both from the root of the project.
You have 2 options to run the project:
1) Command Line
Argument | Description | Info |
---|---|---|
video | Path to the input video | String |
tracks | Select what you want to highlight in the output video | Options: players, goalkeepers, referees, ball, stats |
verbose | Model output and logging | False if left out |
Example:
python main.py --video demos/demo1.mp4 --tracks players referees stats --verbose
2) Frontend
streamlit run frontend/index.py
You can upload your own video or use a demo video. Everything is explained in the frontend.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Distributed under the MIT License. See LICENSE
for more information.