AI-powered tennis match analysis system with real-time player tracking, ball trajectory visualization, and coaching insights.
- 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
# 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# 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.mp4The 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 |
┌─────────────────┐ ┌─────────────────┐
│ Video Input │────▶│ YOLO26 + Track │───▶ Player Positions
└─────────────────┘ └─────────────────┘
│
▼
┌─────────────────┐ ┌─────────────────┐
│ TrackNet │────▶│ Kalman Filter │───▶ Ball Trajectory
└─────────────────┘ └─────────────────┘
│
▼
┌─────────────────┐ ┌─────────────────┐
│ Court Detector │────▶│ Homography │───▶ Coordinate Mapping
└─────────────────┘ └─────────────────┘
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
- Base code: Muhammad Huzaifa
- Ball trajectory concepts: Piotr Skalski
- Court detection model: yastrebksv/TennisCourtDetector
- YOLO: Ultralytics
MIT License