Key Features • How To Use • How It Works • Roadmap • Contributing • Acknowledgements
- Detects the players and the tennis ball in a given video
- Tracks player and ball positions and stores them for later analysis
- Provides and stores some simple stroke statistics for later analysis
- Ticker-styled recreation of the match: play action projected onto a top-view minimap
For this app to work you need to either clone or Git install this repo onto your computer. Make sure to install the requirements along with it. You can do this by running the following command in your command line:
# Pip install with requirements
pip install git+https://github.com/MichlF/sports_object_detection.git -r requirements.txt
In your favorite IDE or in a simple text editor, you can now change the parameters in the config.py
file. The most critical is the VIDEO_IN_NAME
. Change this to your tennis match mp4 file and store that video in the input folder. Then run the main.py
file either from your IDE or the terminal:
python main.py
Note: Running this requires Tensorflow and PyTorch. You may need to install them separately. You can learn how to install Tensorflow here and PyTorch here or run this on a cloud service such as Google Colab or DeepNote.
You can find a detailed explanation of how it works in the wiki.
The following features are in the making (contributions welcome !) and limitations apply.
- Provide an extensive explanation on how it works
- Implement saving the ball trajectory and player path to .csv
- Provide additional metrics
- Provide a counter for the number of strokes
- Provide a counter for the number of ball bounces
- Calculate speed for each ball stroke
- Allow passing arguments from CLI that override config arguments
- Instead of using TrackNet, either implement TrackNetV2 or create a custom dataset and train YOLO to detect the tennis ball reliably. This is likely to massively increase performance as TrackNet accounts for almost 80% of the total processing time.
- Add transformations for video footage with a moving camera (perspective)
- Improve player vs. non-player detection
Because we only have a single camera, certain information, such as depth or height of an object, cannot be reliably inferred. This makes the match recreation on the minimap and certain (physical) metrics inaccurate. Similarly, everything hinges on accuracy of court line and general object detection which means that the quality of your video footage is a major determinant of the output quality (think "garbage in, garbage out").
See the open issues for a full list of proposed features and known issues.
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
- YOLOv8 from Ultralytics
- levan92's DeepSort in realtime algorithm implementation adapted from Wojke, N., Bewley, A., & Paulus, D. (2017, September). Simple online and realtime tracking with a deep association metric. In 2017 IEEE international conference on image processing (ICIP) (pp. 3645-3649). IEEE. The code can be found here.
- TrackNet II as described in Huang, Y. C., Liao, I. N., Chen, C. H., İk, T. U., & Peng, W. C. (2019, September). TrackNet: A deep learning network for tracking high-speed and tiny objects in sports applications. In 2019 16th IEEE International Conference on Advanced Video and Signal Based Surveillance (AVSS) (pp. 1-8). IEEE. The code can be found here.
- Maxime Bataille's repo (find it here)
blog.michelfailing.de · GitHub @MichlF · Twitter @FailingMichel