This project tracks a ball in high-speed footage using YOLO and analyzes its motion (position, velocity, acceleration).
- Detects and tracks a ball in images or videos
- Supports image sequences (
.tif,.png,.jpg) and video files - Exports tracking data to CSV
- Optional debug video with annotations
- MATLAB script for kinematic analysis and visualization
main.py— ball detection and tracking (YOLO-based)config.json— configuration (paths, FPS, model)ballCalc.m— post-processing and plots (trajectory, speed, acceleration)
pip install opencv-python numpy ultralyticsPlace your YOLO model in:
models/or just define which model to use and it should be auto downloaded into the folder.
- Adjust paths and settings in
config.json - Run tracking:
python main.py- Analyze results in MATLAB:
ballCalc.moutput/ball_tracking_results.csv— tracked positionsoutput/ball_tracking_debug.mp4— annotated video (optional)
MATLAB generates:
- Trajectory plot
- Position vs time
- Speed
- Acceleration
- Designed for high-speed recordings (e.g. 5000 FPS)
- Missing detections are interpolated in post-processing
- Uses YOLO tracking via ultralytics