Skip to main content

Real-time sports analytics toolkit built on the Roboflow ecosystem

Project description

SportVision

Real-time sports analytics toolkit built on the Roboflow ecosystem. Detects players and ball via RF-DETR, tracks with ByteTrack, classifies teams by jersey color, and computes possession, speed, distance, and heatmaps.

Features

  • Detection — RF-DETR (base/large) with COCO→sports class mapping
  • Tracking — ByteTrack via supervision with fallback sequential IDs
  • Team Classification — KMeans on HSV jersey histograms
  • Homography — Pixel→field coordinate mapping via cv2.findHomography
  • Analytics — Possession, speed, distance, and heatmap generation
  • Annotation — Team-colored bounding boxes, stats overlay, player trails

Quick Start

pip install "sportvision[all] @ git+https://github.com/MohibShaikh/sportvision.git"
from sportvision.pipeline import SportVisionPipeline

pipeline = SportVisionPipeline()
result = pipeline.process_frame(frame)

Try it on Colab

Open In Colab

Architecture

src/sportvision/
├── detection.py      # SportsDetector — wraps RF-DETR, maps COCO→sports classes
├── tracking.py       # SportsTracker — ByteTrack via supervision
├── teams.py          # TeamClassifier — KMeans on HSV jersey histograms
├── homography.py     # FieldHomography — pixel→field coords
├── analytics/
│   ├── possession.py # PossessionTracker — nearest-player-to-ball per frame
│   ├── speed.py      # SpeedEstimator — displacement/time → km/h
│   ├── distance.py   # DistanceCalculator — cumulative path length
│   └── heatmap.py    # HeatmapGenerator — 2D histogram + gaussian blur
├── annotators.py     # TeamColorAnnotator, StatsOverlayAnnotator, TrailAnnotator
├── pipeline.py       # SportVisionPipeline — orchestrates all modules
└── workflows/
    └── blocks.py     # Roboflow Workflow block stubs

Sports Class IDs

ID Class
0 Player
1 Ball
2 Referee
3 Goalkeeper

Dependencies

Package Purpose Required
numpy Arrays Yes
opencv-python Image processing, annotation Yes
supervision Detection/tracking data structures Yes
scikit-learn KMeans for team classification Yes
rfdetr Detection model Optional ([inference])

Development

git clone https://github.com/MohibShaikh/sportvision.git
cd sportvision
pip install -e ".[all]"

# Tests
pytest tests/ -v

# Lint
ruff check src/ tests/ && ruff format --check src/ tests/

License

Apache-2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sportvision-0.1.0.tar.gz (596.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sportvision-0.1.0-py3-none-any.whl (23.7 kB view details)

Uploaded Python 3

File details

Details for the file sportvision-0.1.0.tar.gz.

File metadata

  • Download URL: sportvision-0.1.0.tar.gz
  • Upload date:
  • Size: 596.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for sportvision-0.1.0.tar.gz
Algorithm Hash digest
SHA256 877484e6ed09da4ea76365be43526f8cbdb8f01fff2aac24c68fc946f900aa95
MD5 11c44b1b050499957aac01de76b9ddfd
BLAKE2b-256 d0016e1872aecc3081264eb6bde057cf1b5d15dbea9a9e6d24c6ff82a0f27d91

See more details on using hashes here.

File details

Details for the file sportvision-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: sportvision-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 23.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.12

File hashes

Hashes for sportvision-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 7fb52588b5323ee2b8513941d91a924a1ca3392310dd90486961c8587a267153
MD5 e06190ce9f8607dc277c6019e5c2eab1
BLAKE2b-256 10aad4a409e0f87bd873d7e4965f27e27e089a096c32030fb567e03947c4d275

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page