The Journey to Automated Badminton Rally Detection

From frustration to solution: How computer vision solved a real problem in sports video analysis.

The Problem

As a badminton player and coach, I often record match footage for analysis. But there was a frustrating bottleneck: manually splitting a 30-minute match video into individual rally clips would take hours of tedious work.

I needed to:

  • Identify when each rally started and ended
  • Extract clips for each point
  • Organise them by player for analysis
  • Count shots and analyse patterns

This manual process was killing my motivation to analyse footage. There had to be a better way.

The Deep Learning Solution

I turned to deep learning-based object detection models. After evaluating several architectures, I landed on RF-DETR (Real-Time Detection Transformer), a transformer-based detector that excels at small object detection tasks.

Since shuttlecocks aren't in standard datasets, I had to collect and annotate custom training data.

The Training Process

  1. Data Collection: Extracted frames from badminton match footage
  2. Manual Annotation: Drew bounding boxes around shuttlecocks using labelImg
  3. Dataset Creation: Curated 244 high-quality annotated images
  4. Data Split: 195 training, 24 validation, 25 test images (80/10/10 split)
  5. Model Training: 200 epochs with RF-DETR Medium (ResNet-50 backbone)

Model Evolution

After experimenting with different detection architectures, RF-DETR emerged as the clear winner:

  • Transformer Architecture: Better at capturing spatial relationships
  • Small Object Detection: Excels at detecting tiny shuttlecocks
  • High Precision: 85.7% precision minimizes false positives
  • Balanced Performance: 80% F1-score for production deployment

The Results (RF-DETR v2.0)

The system has been upgraded to RF-DETR (Detection Transformer), achieving improved accuracy and precision:

85.7%
Precision
75.0%
Recall
80.0%
F1-Score
200
Training Epochs

What used to take hours of manual work now happens automatically with transformer-based object detection. The RF-DETR model successfully detects shuttlecocks with 85.7% precision (minimising false positives like rackets), and processes rally footage ready for analysis.

Technical Stack

🤖 Machine Learning

  • ✅ RF-DETR Medium
  • ✅ PyTorch Framework
  • ✅ 244 Annotated Images
  • ✅ 200 Training Epochs
  • ✅ 85.7% Precision

📹 Video Processing

  • ✅ OpenCV
  • ✅ Supervision Library
  • ✅ NumPy
  • ✅ FFmpeg
  • ✅ Real-time Inference

🌐 Web Application

  • ✅ Flask Backend
  • ✅ Vanilla JavaScript
  • ✅ Modern CSS3
  • ✅ Responsive Design
  • ✅ RESTful API

🚀 Infrastructure

  • ✅ Nginx Proxy
  • ✅ Gunicorn WSGI
  • ✅ Systemd Service
  • ✅ SSL/TLS
  • ✅ Cloud Deployment

Key Insights

Quality Over Quantity

244 carefully annotated images proved sufficient for training an effective detection model

Architecture Matters

Transformer-based models excel at small object detection tasks like shuttle tracking

Precision Priority

Choosing the right confidence threshold (0.5) minimizes false positives in production

Extended Training

200 training epochs with proper validation ensured model convergence and stability

Future Work

While the current system works well, there's room for improvement:

  • Automatic player attribution: Use pose detection to identify who won each rally
  • Shot classification: Distinguish between smashes, clears, drops, and net shots
  • Trajectory analysis: Track shuttle flight paths for tactical insights
  • Real-time processing: Enable live rally detection during streaming matches
  • Multi-court support: Expand to outdoor courts and different lighting conditions

Try It Yourself!

Explore the demo to see the model results on 6 real badminton rally clips.

All videos have been pre-processed with RF-DETR detection annotations.

View Demo →