Skip to content

MichlF/sports_object_detection

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation


From Flaticon Those Icons
Object Detection in Sports

— A Tennis match tracking project —

Contributors Forks Stargazers Issues

Key FeaturesHow To UseHow It WorksRoadmapContributingAcknowledgements

Report BugRequest Feature

Demo

Key Features

  • 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

(back to top)

How To Use

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.

(back to top)

How It Works

You can find a detailed explanation of how it works in the wiki.

(back to top)

Roadmap

The following features are in the making (contributions welcome !) and limitations apply.

Features to add

  • 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

Limitations

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").

More features? Problems or bugs?

See the open issues for a full list of proposed features and known issues.

(back to top)

Contributing

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!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

Acknowledgements

  • 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)

(back to top)


blog.michelfailing.de  ·  GitHub @MichlF  ·  Twitter @FailingMichel

About

Object detection and tracking in sports videos

Resources

Stars

Watchers

Forks

Languages