Skip to content

nomiscientist/yolo_player_detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 

Repository files navigation

Football Player Detection & Tracking

Detects and tracks football players in video using YOLOv8 and BoT-SORT.

Quick Start

# Create virtual environment
python -m venv venv
venv\Scripts\activate  # Windows
# source venv/bin/activate  # Linux/Mac

# Install dependencies
pip install ultralytics opencv-python lap

# Run detection
python detect_players.py

Technical Approach

Detection: YOLOv8

  • Uses YOLOv8n (nano) pre-trained on COCO dataset
  • Filters detections to class 0 ("person") only
  • Confidence threshold: 0.3
  • Can swap to yolov8s/m/l/x for better accuracy (slower)

Tracking: BoT-SORT

  • BoT-SORT (Bag of Tricks for SORT) tracker
  • Combines Kalman filter motion prediction with appearance features (Re-ID)
  • Handles occlusions and maintains consistent IDs across frames
  • Well-suited for sports with fast, erratic movement

Pipeline

Video Frame → YOLOv8 Detection → BoT-SORT Association → Annotated Frame
                    ↓                    ↓
              Person boxes         Track IDs assigned
              + confidence         + history maintained

Output Visualization

  • Colored bounding boxes (unique per player)
  • Labels: Player {ID} {confidence}
  • Yellow movement trails (last 30 positions)

Configuration

Edit detect_players.py to change:

  • max_seconds - Duration to process (default: 10s)
  • conf - Detection confidence threshold (default: 0.3)
  • Model size - Replace yolov8n.pt with yolov8m.pt for better accuracy

Output

Generates output_annotated.mp4 with tracked players labeled and color-coded.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages