This project is designed to analyze football (soccer) game footage using computer vision and machine learning techniques. It tracks players and the ball, assigns teams to players, and identifies which team has possession of the ball at any given time. The output is an annotated video with visualizations of player movements, team assignments, and ball possession.
The project processes video footage of a football game to:
- Track Players and the Ball: Using a pre-trained object detection model, it identifies and tracks players and the ball throughout the video.
- Assign Teams: It assigns a team (e.g., Team A or Team B) to each player based on their jersey color.
- Ball Possession Analysis: It determines which team has possession of the ball at any given time.
- Visualization: The final output is an annotated video with bounding boxes, team colors, and ball possession information.
-
Object Detection Model:
- A pre-trained YOLO (You Only Look Once) model (
best.pt
) is used to detect and track players and the ball in the video. - The model is fine-tuned for football game footage to ensure accurate detection.
- A pre-trained YOLO (You Only Look Once) model (
-
Team Assigner:
- A custom algorithm assigns teams to players based on their jersey colors.
- It uses the first frame of the video to determine team colors.
-
Ball Assigner:
- A custom algorithm determines which player is closest to the ball and assigns ball possession to the corresponding team.
To run this project, you need the following Python libraries and tools:
- OpenCV: For video processing and visualization.
- NumPy: For numerical operations.
- scikit-learn: For clustering and distance calculations (if needed).
- cvzone: A helper library for OpenCV.
- supervision: For annotation and visualization.
- PyTorch: For running the YOLO model.
Install the required libraries using pip
:
pip install -r requirements.txt