EFootball is a computer vision-based project that applies deep learning techniques to analyze football matches in real time. By leveraging neural networks, the system extracts key statistics and provides valuable insights into player positioning, ball possession, and team strategies.
The goal of the project is to enhance the understanding of match dynamics by automatically tracking players and the ball, segmenting teams, and mapping movements onto a 2D field representation. This enables a more in-depth tactical analysis, helping coaches, analysts, and fans gain a deeper perspective on the game.
While still a Proof of Concept (POC), EFootball showcases the potential of AI-driven sports analytics, offering a foundation for more advanced solutions in the future.
EFootball was developed using publicly available datasets and deep learning frameworks. The DFL Bundesliga Data Shootout dataset from Kaggle provided professional matches, enabling precise player and ball analysis.
For player detection, the project used Detectron2, an object detection framework by Facebook Research, to accurately identify and track players on the field. These resources were essential in building an AI-driven system for match analysis.
To identify players on the field, the project utilizes a pre-trained model from Detectron2, an advanced object detection framework developed by Facebook AI. The model is based on Mask R-CNN with a ResNet-50 backbone, fine-tuned on the COCO dataset, which includes thousands of labeled images of people and objects.
The detection process involves loading the model, setting a confidence threshold, and processing each frame to identify player positions. Below is the core implementation used in the project
To differentiate the two teams on the field, the project employs a clustering algorithm based on jersey colors. This process begins by analyzing the first frame of the video, identifying all players present in the image.
For each detected player, an RGB color profile is generated by calculating the average Red, Green, and Blue values of their jersey. These values are then stored as a tuple (R, G, B) for each player. Using K-Means clustering, the algorithm groups players into two distinct clusters, effectively segmenting the teams.
This approach allows for a reliable team identification system, ensuring accurate tracking of possession, player movements, and tactical analysis throughout the match.
To accurately track the ball during the game, a custom model was trained using football ball detection data from Roboflow (https://universe.roboflow.com/roboflow-jvuqo/football-ball-detection-rejhg). Unlike players, the ball is smaller and moves rapidly, making detection more challenging.
The model was trained on Detectron2's RetinaNet architecture, which is optimized for small object detection. By fine-tuning the network on a specialized dataset, the model achieves better precision in identifying the ball across different frames.
To map the detected players onto a 2D field representation, the project utilizes a homographic transformation model. This technique allows for the precise projection of player positions from the video frame onto a top-down view of the pitch, enabling tactical analysis.
The implementation is based on the Narya model (https://donsetpg.github.io/blog/2020/12/24/Narya/), which uses deep learning to estimate the perspective transformation. By applying this transformation, each player’s coordinates in the video are repositioned to match their real-world location on the field.
This projection makes it possible to analyze team formations, defensive structures, and movement patterns, providing deeper insights into possession dynamics and space control.
To extract key insights from the match, the project generates statistics based on the positions of players and the ball. A simplified approach assumes that the player closest to the ball has possession at any given moment. Using this method, the system calculates ball possession percentages for each team, providing a fundamental metric to analyze team dominance and game dynamics.