This project analyzes football videos to detect valid players, keep a stable identifier for each player, and classify each player as Team A or Team B based on shirt colors.
main.pyreads the video and coordinates the full execution.extract_players.pydetects players with YOLO, applies ByteTrack, and usesstubs/as a track cache.trackers/stabilizes IDs, merges fragmented tracks, and filters goalkeepers/referees.labeling.pyassigns a stable team to eachtrack_id.team_assigner/extracts visual shirt features and applies K-Means to separate Team A and Team B.trackers/drawing.pydraws the final inferences on the output video: boxes, IDs, and assigned team.manual_track_accuracy.pygenerates evidence to manually evaluate tracks and teams.
OpenCV: reading, writing, and manipulating video frames.Ultralytics YOLO: detecting players, goalkeepers, and referees.Supervision: ByteTrack integration for object tracking.NumPy: numerical calculations for boxes, positions, and visual features.Scikit-learn: K-Means and normalization for team classification.PyTorch: backend used by the YOLO model.
Process the default video:
python main.pySet input and output paths:
python main.py --input input_videos/110.mp4 --output output_videos/110_result.aviRecalculate tracks without using cache:
python main.py --input input_videos/110.mp4 --output output_videos/110_result.avi --no-stubsGenerate one evidence sample for each track_id and save results as CSV/JSON:
python manual_track_accuracy.py --video input_videos/110.mp4Options during the review:
| Key | Meaning |
|---|---|
s |
Valid player and correct team. |
n |
Valid player, incorrect team. |
t |
Not a valid player. |
k |
Skip ID. |
q |
Quit and save. |