Skip to content

Using machine learning (computer vision & deep learning) to analyse football match parameters such as ball possession, tracking players and more.

License

Notifications You must be signed in to change notification settings

JanSkn/football-computer-vision

Repository files navigation


Logo

MatchVision

Automated football match analysis using Computer Vision.
Explore the docs »

Report Bug · Request Feature


About The Project

The project called MatchVision allows tracking the ball, referees and players, treating players individually by ID and assigning them to a team, displaying ball possession and estimating the camera movement.


Training

The model was trained on Google Colab's servers with T4 GPU (~ 45 mins.)

It uses a custom trained YOLOv5 model.

Benefits:

  • better ball tracking
  • not tracking persons outside the pitch

Structure

The YOLO model detects the bounding boxes of the objects. They get stored in a dictionary along with the tracking ID, the team ID, the position etc.

The team detection is based on KMeans clustering.

To improve the ball highlighting, the ball position gets interpolated with Pandas.

The camera movement gets estimated with optical flow to adjust the object positions.


Input Video Example

image



Result

image

(back to top)

Built With

The source code was built with Python, mainly using Ultralytics, OpenCV and NumPy.

(back to top)

Requirements

Requirements can be found under requirements.txt.

pip install -r requirements.txt

(back to top)

Usage

Warning: Run both from the root of the project.

You have 2 options to run the project:


1) Command Line

Argument Description Info
video Path to the input video String
tracks Select what you want to highlight in the output video Options: players, goalkeepers, referees, ball, stats
verbose Model output and logging False if left out

Example:

python main.py --video demos/demo1.mp4 --tracks players referees stats --verbose

2) Frontend

streamlit run frontend/index.py

You can upload your own video or use a demo video. Everything is explained in the frontend.


image

(back to top)

Contributing

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

  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)

License

Distributed under the MIT License. See LICENSE for more information.

(back to top)

About

Using machine learning (computer vision & deep learning) to analyse football match parameters such as ball possession, tracking players and more.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published