Skip to content

Repository files navigation

🎾 Tennis Pro Analytics

AI-powered tennis match analysis system with real-time player tracking, ball trajectory visualization, and coaching insights.

Tennis Pro Analytics

Features

  • YOLO26 Player Detection - Latest YOLO26n for robust player tracking with ByteTrack
  • TrackNet Ball Detection - Precise ball tracking even during fast rallies
  • Court Detection - Deep learning-based court keypoint detection with homography mapping
  • Physics-aware Trajectory Smoothing - Kalman filter + outlier rejection for realistic ball paths
  • Player Position Heatmaps - Visualize court coverage patterns
  • Coaching Stats - Rally count, ball speed (km/h), shot depth analysis

Installation

# Clone the repository
git clone https://github.com/Xsolai/Tennis-Pro-Analytics.git
cd Tennis-Pro-Analytics

# Create virtual environment
python3 -m venv venv
source venv/bin/activate

# Install dependencies
pip install -r requirements.txt

Usage

# Analyze a tennis video
python main.py --video your_video.mp4 --output analysis_output.mp4

# With custom model paths
python main.py --video match.mp4 --tracknet-weights model_best.pt --output result.mp4

Model Weights

The repository includes pre-trained model weights:

Model File Purpose
YOLO26n yolo26n.pt Player detection (auto-downloads if missing)
TrackNet model_best.pt Ball detection
Court Detector model_tennis_court_det.pt Court keypoint detection

Architecture

┌─────────────────┐     ┌─────────────────┐
│   Video Input   │────▶│  YOLO26 + Track │───▶ Player Positions
└─────────────────┘     └─────────────────┘
         │
         ▼
┌─────────────────┐     ┌─────────────────┐
│    TrackNet     │────▶│ Kalman Filter   │───▶ Ball Trajectory
└─────────────────┘     └─────────────────┘
         │
         ▼
┌─────────────────┐     ┌─────────────────┐
│ Court Detector  │────▶│   Homography    │───▶ Coordinate Mapping
└─────────────────┘     └─────────────────┘

Output

The analyzer generates:

  • Side-by-side video - Original footage + trajectory analysis canvas
  • JSON stats - Match statistics in JSON format
  • CSV trajectory - Frame-by-frame ball position data

Credits

License

MIT License

About

No description, website, or topics provided.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages