This project is a multi-module program designed to analyze football matches by tracking all players, referees, and the ball. The system overlays each player with an ID, speed, and distance covered, while also tracking the ball with a directional arrow. This project leverages advanced computer vision techniques, including object detection, image clustering, and perspective transformation.
- Player & Referee Tracking: Identifies and tracks all players and referees on the field.
- Overlay Information: Displays player ID, speed, and distance covered in real-time.
- Ball Tracking: Tracks the ball's movement with a directional arrow.
- Camera Movement Estimation: Estimates camera movement to accurately calculate player speed and distance.
- View and Perspective Transformation: Adjusts the view to calculate speed and distance in the correct perspective.
- Interpolation: Fills in missing bounding boxes to maintain continuous tracking.
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
- Speed and distance calculation per player
- Object Detection: The system uses a custom-trained YOLO model to detect all players, referees, and the ball on the field.
- Tracking: Once detected, objects are tracked frame by frame, with the system calculating speed and distance covered for each player.
- Ball Tracking: The ball is tracked separately, with an arrow indicating its movement.
- Data Overlay: Real-time overlay information, including player IDs, speed, and distance, is displayed on the video.
- Camera Movement Estimation: The system calculates the camera movement to ensure accurate measurements of player statistics.
- Perspective Transformation: The video is transformed to maintain consistent perspective, ensuring accurate distance and speed calculations.
-
Clone the repository from GitHub.
-
Install the required dependencies by using the
requirements.txtfile.
Run the main script to start analyzing a football match. The output video with overlays will be saved in the output/ directory.
- Enhanced Ball Tracking: Further refine the logic for more accurate ball tracking.
- Real-time Analysis: Develop capabilities for real-time match analysis.
- Advanced Statistics: Include more advanced statistics such as player acceleration, team formations, and heat maps.
Special thanks to Abdullah Tarek for his amazing tutorial! His Youtube Channel
This project is licensed under the MIT License.
