This project is a solution for the Machine Learning Internship assignment from a Stealth Mode startup. It focuses on player re-identification in sports analytics, a critical task for tracking players across video frames.
The chosen task is Option 2: Re-Identification in a Single Feed. The objective is to identify each player in a 15-second video clip (15sec_input_720p.mp4) and maintain a consistent ID for each player, even if they are temporarily occluded or leave the frame.
This project aims to accurately detect and track football players in a 15-second video clip. The primary goal is to implement a robust tracking system that assigns and maintains a persistent ID for each player, even when they are temporarily occluded or leave and re-enter the frame.
The key requirements are:
- Track only players (class_id = 0).
- Completely ignore the ball (class_id = 1).
- Maintain ID consistency using a combination of motion and appearance cues.
- Player Detection: A pre-trained YOLOv11 model (
best.pt) is used to detect players and the ball in each frame of the video. - Player Tracking & Re-Identification: A custom tracking algorithm is implemented to assign and maintain unique IDs for each detected player. This involves using appearance-based features (e.g., color histograms) to re-identify players who re-enter the scene.
The tracking pipeline is designed to be robust and focus solely on players:
- Player-Only Filtering: The system first detects all objects, then explicitly filters out all non-player detections (like the ball) before they are processed by the tracker. This ensures the tracker only ever receives player data.
- Hybrid Tracking Algorithm: Player IDs are maintained using a two-stage matching process:
- IoU Matching: Active tracks are first matched with new detections based on Intersection over Union (IoU) to handle smooth, continuous motion.
- Appearance Re-Identification (ReID): If a player is lost (e.g., occluded) and later reappears, their ID is recovered by comparing the appearance features (HSV color histograms) of the new detection with those of lost tracks.
- Modular Design: The ball is ignored by default, but the modular code allows for a separate ball tracker to be added easily outside the
PlayerTrackerclass if needed in the future.
.STEALTH/
├── data/ # Input video files
│ ├── 15sec_input_720p.mp4
│ ├── broadcast.mp4
│ └── tacticam.mp4
├── models/ # Pre-trained models
│ └── best.pt
├── output/
├── src/ # Source code
│ ├── main.py # Main script to run the pipeline
│ ├── tracker.py # Core PlayerTracker class
│ └── reid_utils.py # Utilities for appearance feature extraction
├── requirements.txt # Project dependencies
├── README.md # This file
└── report.md
-
Clone the repository
-
Create a virtual environment and activate it:
python -m venv venv source venv/bin/activate -
Install dependencies:
pip install -r requirements.txt
Execute the main script from within the src directory:
cd src
python main.pyThe processed video will be saved in the output/ directory.