Skip to content

Albi1999/Tennis_Sport_Analysis

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

103 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

From Pixels to Points: AI-Powered Tennis Match Insights

Python Latex Visual Studio Code Overleaf Google Colab Jupyter Git GitHub

Overview

This repository contains the project for the "Vision and Cognitive Systems" course.

This project provides a comprehensive suite of computer vision tools for detailed analysis of tennis matches. Our system is designed to extract key insights from tennis videos by detecting and tracking players and the ball, identifying important events like racket hits and ball bounces, and analyzing game dynamics. We also developed a novel method to predict player score probabilities based on a ball and score heatmap

The core contributions of this project include:

  • Ball Bounce Detection: We developed a new deep learning method that treats bounce detection as a visual pattern recognition problem. Our approach uses a lightweight Convolutional Neural Network (CNN) combined with DBSCAN clustering to achieve an $84$% accuracy in detecting true bounces within a 2-frame tolerance.
  • Racket Hit Detection: We created an audio-visual approach that combines audio signals with visual cues to detect when a player hits the ball. This method demonstrated an $84.74$% accuracy within a 6-frame range.
  • Score Probability Prediction: Our system introduces a computer vision-based method to predict shot-by-shot score probabilities by analyzing the ball's estimated landing position and the opponent's location.

Our work represents a significant step forward in automated sports analysis, providing tools that can give viewers and analysts much deeper insights into tennis matches.

Results

Racket Hit Detection

Our model achieved an 84.74% accuracy in detecting racket hits within 6 frames of the actual event and a 72.11% accuracy within a 2-frame tolerance. The system missed some hits in $22.86$% of the videos and detected false positives in $11.43$% of the videos.

Ball Bounce Detection

We developed a custom dataset for bounce detection and formulated the problem as a binary classification task. The model's performance was evaluated using precision, recall, and F1-score. Our CNN model, when combined with DBSCAN clustering for exact frame prediction, achieved an 84% accuracy in detecting true bounces with a tolerance of $\pm2$ frames. The table below summarizes the model's performance metrics.

Precision Recall F1 Score
$0.7429$ $0.8966$ $0.8125$

Courtline Prediction

Using a fine-tuned ResNet-34 model, we predicted the coordinates of 14 key court points. The model was trained with MSE loss and achieved a total loss of 1.16 on the training set and 9.26 on the validation set.

Project Report

The complete project report can be found here:

Installation and Setup

Clone the Repository

git clone https://github.com/danielevirzi/Tennis_Sport_Analysis.git

Install Dependencies

pip install -r requirements.txt

Run the Code

python main.py

Project Structure

  • main.py: Entry point for running the analysis pipeline.
  • data_scrapert/: Scripts for scraping video data.
  • ball_landing/: Code for ball landing detection.
  • court_line_detector/: Code for detecting and predicting court lines.
  • data/: Contains datasets used for training and evaluation.
  • mini_court/: Code for court detection and line prediction.
  • models/: Pre-trained models and architecture definitions.
  • output/: Stores output videos and results.
  • other/: Contains images, logos, and other media files.
  • trackers/: Player and ball tracking algorithms.
  • training/: Scripts and notebooks for training models.
  • utils/: Utility functions for data processing and visualization.

Contributors

For contributions, suggestions, or inquiries, feel free to reach out.

License

This project is open-source under the MIT License. See LICENSE for more information.

About

Academic group project for the Vision and Cognitive Systems Course of the MSc in Data Science @ UniPD 2024/2025

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages

  • Jupyter Notebook 80.0%
  • Python 20.0%