This project employs advanced computer vision techniques like YOLOv5 and OpenCV to identify and track players, referees, and footballs in videos. I have used different techniques in order to process video frame for including various components such as Speed and Distance Travelled for players.
In addition, we also employed K-means clustering for pixel segmentation, enabling us to assign players to their respective teams based on the color of their jerseys. This data will allow us to calculate the percentage of ball possession for each team during a match, providing valuable insights into the game dynamics.
I also incorporated optical flow techniques to measure the movement of the camera between frames, which will facilitate accurate tracking of player movements. To further refine our measurements, we will implement perspective transformation to depict the depth and perspective of the scene. This will allow us to measure player movements in real-world units (meters) instead of pixels, providing a more realistic representation of the game.
Finally, we will compute the speed of each player and the total distance they cover during the match. This comprehensive project encompasses a wide range of concepts and tackles real-world challenges, making it an excellent learning opportunity for me.
Here, we will also be fine-tuning YOLO model on football dataset before video processing to enhance its performance and ensure precise detection.
This project is inspired from a kaggle competition DFL - Bundesliga Data Shootout.
The following modules are used in this project:
- YOLO: AI object detection model
- Kmeans: Pixel segmentation and clustering to detect t-shirt color
- Optical Flow: Measure camera movement
- Perspective Transformation: Represent scene depth and perspective
I have already fine tuned the YOLOv5 on Roboflow dataset which can be accessed from:
This model tracks all the players, referee and ball quite well. Refer to below videos for results.
To run this project, you need to have the following requirements installed:
- Python 3.x
- ultralytics
- supervision
- OpenCV
- NumPy
- Matplotlib
- Pandas