The goal of this project is to build a python script to analyze a tennis video, to track the tennis ball, detect players and identify shots, using standard video processing techniques and a just little bit of ML (yolo). This work is based on a previous existent work, actually being an enhancement of it. The script keeps previous obtained results, adjusts some of them and performs new computations to a deeper analysis of the tennis video.
- Tennis ball detection
- Trajectory drawing, for ball visual tracking
- Direction and in/out detection and printing
For more info, visit the project GitHub.
- Correction of tennis ball direction
- Script to find the tennis field perimeter, using color (entire field, including alleys)
- Detect single field lines and perimeter, using line detection
- Projection of the tennis ball in a 2d field, from a top view.
- Detection of bottom player's shots (backhand, forehand, serve) using YOLOv8 to detect his tennis racket
- Identification of the type of shot made by the bottom player, based on position and estimated direction (center, cross-court, down-the-line, inside-in, inside-out).
-
Initialize the workspace
git clone https://github.com/luckeez/siv-project-tennis cd siv-project-tennis
-
Download YOLOv8n.pt model and save it within the workspace just created.
-
Run the project.
python3 src/main.py
Arguments:
- -v, --video: video path (default: "tennis_match.mp4").
- -b, --buffer: max buffer size for trajectory draw (default: 64).
- -y, --yolo: y/n to visualize or not yolo detection (default: "n").
Example
python3 src/main.py --video tennis_match_2.mp4 --buffer 32 --yolo y