Skip to content

This repository contains a comprehensive computer vision/machine learning football project that uses YOLO for object detection, Kmeans for pixel segmentation, optical flow for motion tracking, and perspective transformation to analyze player movements in football videos

License

Notifications You must be signed in to change notification settings

Chaganti-Reddy/Football-Analysis-YOLO

Repository files navigation

Football Analysis using YOLO and CNNsn

This project analyzes Football players in a video to measure their speed, ball control and more.

😇 Introduction

The goal of this project is to detect and track players, referees, and footballs in a video using YOLO, one of the best AI object detection models available. We will also train the model to improve its performance. Additionally, we will assign players to teams based on the colors of their t-shirts using Kmeans for pixel segmentation and clustering. With this information, we can measure a team's ball acquisition percentage in a match. We will also use optical flow to measure camera movement between frames, enabling us to accurately measure a player's movement. Furthermore, we will implement perspective transformation to represent the scene's depth and perspective, allowing us to measure a player's movement in meters rather than pixels. Finally, we will calculate a player's speed and the distance covered. This project will be useful for football coaches, analysts, and fans who want to analyze a player's performance in a match.

Table of Contents

⭐ Features

  • Player Detection: Detects players in the video using YOLO Models.
  • Foot Ball Detection: Detects Football in the video continuously.
  • Ball COntrol: Measures the ball control of the players.
  • Speed Measurement: Measures the speed of the players.
  • Distance Measurement: Measures the distance covered by the players.

⚠️ Frameworks and Libraries

  • YOLO - YOLO is a state-of-the-art, real-time object detection system. It is a deep learning algorithm that can detect objects in real-time. YOLO is a clever neural network for doing object detection in real-time. YOLO stands for 'You Only Look Once'.
  • PyTorch - PyTorch is an open source machine learning library based on the Torch library. It is used for applications such as natural language processing. It is primarily developed by Facebook's AI Research lab.
  • OpenCV - OpenCV is a library of programming functions mainly aimed at real-time computer vision. Originally developed by Intel, it was later supported by Willow Garage then Itseez. The library is cross-platform and free for use under the open-source BSD license.
  • CNNs - In deep learning, a convolutional neural network (CNN, or ConvNet) is a class of deep neural networks, most commonly applied to analyzing visual imagery.
  • KMeans - K-means clustering is a method of vector quantization, originally from signal processing, that aims to partition n observations into k clusters in which each observation belongs to the cluster with the nearest mean.
  • Optical Flow - Optical flow or optic flow is the pattern of apparent motion of objects, surfaces, and edges in a visual scene caused by the relative motion between an observer and a scene.
  • Perspective Transformation - Perspective transformation is a way to represent 3D objects in a 2D plane. It is used to represent the depth and perspective of a scene.

📁 Datasets

The DataSet used for this project is collected from Roboflow.

📂 Directory Tree

.
├── camera_movement_estimator
├── development_and_analysis
├── input_videos
├── models
├── output_videos
├── player_ball_assigner
├── speed_and_distance_estimator
├── stubs
├── team_assigner
├── trackers
├── training
├── utils
└── view_transformer

💡 Models Used

  • YOLO: AI object detection model
  • Kmeans: Pixel segmentation and clustering to detect t-shirt color
  • Optical Flow: Measure camera movement
  • Perspective Transformation: Represent scene depth and perspective
  • Speed and distance calculation per player
  • And a trained model -- Trained Yolo v5

🚀  Installation & Running

  1. Clone the repository and navigate to the directory
git clone https://github.com/Chaganti-Reddy/Football-Analysis-YOLO.git && cd Football-Analysis-YOLO
  1. Change the path of video file to be analyzed in the main.py file.

  2. Install these requirements.

  • python3.8
  • ultralytics
  • pytroch
  • pandas
  • numpy
  • opencv
  1. Sample input video - Use this video to test the application.

  2. Then run the following command to run the application.

python main.py

👏 And it's done!

Feel free to mail me for any doubts/query :email: Mail to Me 😄


🙋 Citation

You are allowed to cite any part of the code or our dataset. You can use it in your Research Work or Project. Remember to provide credit to the Maintainer Chaganti Venkatarami Reddy by mentioning a link to this repository and her GitHub Profile.

Follow this format:

  • Author's name - Name
  • Date of publication or update in parentheses.
  • Title or description of document.
  • URL.

👀 License

MIT © Chaganti Reddy

About

This repository contains a comprehensive computer vision/machine learning football project that uses YOLO for object detection, Kmeans for pixel segmentation, optical flow for motion tracking, and perspective transformation to analyze player movements in football videos

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published