Git Product home page Git Product logo

ml-auto-baseball-pitching-overlay's Introduction

⚾ Automatically overlaying pitch motion and trajectory with machine learning!

This work is now published in ACM ICMR 2021!

This project takes your baseball pitching clips and automatically generates the overlay. The input pitching clip could be directly from your phone or camera. The release point will be automatically detected by the program. This system will trace the trajectory and align all the videos to generate the overlay.

A fine-tuned YOLOv4 model is used to get the location of the ball. Then, I implemented SORT tracking algorithm to keep track of each individual ball. Lastly, I have applied some image registration techniques to deal with slight camera shift on each clip.

I'm still trying to improve it! Feel free to follow this project, also check out the Todo list.

πŸ’» Getting Started

These instructions will get you a copy of the project, and generates your own pitching overlay clip!

Get a copy

Get a copy of this project by simply running the git clone command.

git clone https://github.com/chonyy/ML-auto-baseball-pitching-overlay.git

Prerequisites

Before running the project, we have to install all the dependencies from requirements.txt

pip install -r requirements.txt

Overlay!

Last, run the project with your own clips!

Try a sample

python pitching_overlay.py

Try with yout own clips

Place your pitching videos in a folder, then specify the path in the CLI.

python pitching_overlay.py --videos_folder "./videos/videos"

πŸ”¨ Project Structure

🎬 More Demo

β˜‘οΈ Todo

  • Implement image registration to deal with camera shift
  • Build a demo web app for people to use it in realtime on web
  • Enable custom parameter tuning
  • Improve the visual effect
  • Write a Medium post to explain the technical workflow
  • Draw a structure diagram

ml-auto-baseball-pitching-overlay's People

Contributors

chonyy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ml-auto-baseball-pitching-overlay's Issues

Hoping for Help

This is phenomenal work. However, I can't get it to work with some college baseball videos I've pulled and I was hoping for help. I've been using HD ESPN streams but I always get the "Error: Sorry we could not get enough baseball detection from the video, video output.mp4 will not be overlayed
expected non-empty vector for x" issue.

Wonder if you had any tips?

Baseball Dataset

Hey, cool project you got going on, I'm currently looking to also work on it, but was wondering if you are willing to share a labeled baseball dataset? At least I assume you manually created a dataset for the yolov4 model to fine-tune on, am I right? If you would rather not share it, then I understand that completely, just wondering!

Kind regards

Great Work

Hi
Appreciate sharing this publically. Could you please let me know where I can find the dataset?
Babak

Error while installing requirements

Hello, could you please land me a hand?

I'am getting this kind of issue:

ImportError: cannot import name 'soft_unicode' from 'markupsafe' (full traceback below)

Googling this error I found that there's a mismatch in package dependencies, mainly the markupsafe library.
I played around with various versions of the packages but didn't get it in an functional state.

I tried to install it on Python 3.7, 3.8 and 3.10

Can you please update the requirements file or give a hint how to install it?

Thanks, Marek

` ERROR: Command errored out with exit status 1:
command: /Users/jardik/Documents/overlay/ML-auto-baseball-pitching-overlay/env-MLauto/bin/python3 /Users/jardik/Documents/overlay/ML-auto-baseball-pitching-overlay/env-MLauto/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /var/folders/vx/5x_d29f50t7387_bmsjsc8700000gn/T/tmp8cv3k60q
cwd: /private/var/folders/vx/5x_d29f50t7387_bmsjsc8700000gn/T/pip-install-g_jmq3w8/astropy
Complete output (28 lines):
Traceback (most recent call last):
File "/Users/jardik/Documents/overlay/ML-auto-baseball-pitching-overlay/env-MLauto/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 207, in
main()
File "/Users/jardik/Documents/overlay/ML-auto-baseball-pitching-overlay/env-MLauto/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 197, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/Users/jardik/Documents/overlay/ML-auto-baseball-pitching-overlay/env-MLauto/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 54, in get_requires_for_build_wheel
return hook(config_settings)
File "/private/var/folders/vx/5x_d29f50t7387_bmsjsc8700000gn/T/pip-build-env-kxuy583w/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 177, in get_requires_for_build_wheel
return self._get_build_requires(
File "/private/var/folders/vx/5x_d29f50t7387_bmsjsc8700000gn/T/pip-build-env-kxuy583w/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 159, in _get_build_requires
self.run_setup()
File "/private/var/folders/vx/5x_d29f50t7387_bmsjsc8700000gn/T/pip-build-env-kxuy583w/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 174, in run_setup
exec(compile(code, file, 'exec'), locals())
File "setup.py", line 70, in
ext_modules=get_extensions())
File "/private/var/folders/vx/5x_d29f50t7387_bmsjsc8700000gn/T/pip-build-env-kxuy583w/overlay/lib/python3.8/site-packages/extension_helpers/_setup_helpers.py", line 67, in get_extensions
ext_modules.extend(setuppkg.get_extensions())
File "./astropy/modeling/setup_package.py", line 59, in get_extensions
from jinja2 import Environment, FileSystemLoader
File "/private/var/folders/vx/5x_d29f50t7387_bmsjsc8700000gn/T/pip-build-env-kxuy583w/overlay/lib/python3.8/site-packages/jinja2/init.py", line 33, in
from jinja2.environment import Environment, Template
File "/private/var/folders/vx/5x_d29f50t7387_bmsjsc8700000gn/T/pip-build-env-kxuy583w/overlay/lib/python3.8/site-packages/jinja2/environment.py", line 15, in
from jinja2 import nodes
File "/private/var/folders/vx/5x_d29f50t7387_bmsjsc8700000gn/T/pip-build-env-kxuy583w/overlay/lib/python3.8/site-packages/jinja2/nodes.py", line 19, in
from jinja2.utils import Markup
File "/private/var/folders/vx/5x_d29f50t7387_bmsjsc8700000gn/T/pip-build-env-kxuy583w/overlay/lib/python3.8/site-packages/jinja2/utils.py", line 642, in
from markupsafe import Markup, escape, soft_unicode
ImportError: cannot import name 'soft_unicode' from 'markupsafe' (/private/var/folders/vx/5x_d29f50t7387_bmsjsc8700000gn/T/pip-build-env-kxuy583w/overlay/lib/python3.8/site-packages/markupsafe/init.py)

ERROR: Command errored out with exit status 1: /Users/jardik/Documents/overlay/ML-auto-baseball-pitching-overlay/env-MLauto/bin/python3 /Users/jardik/Documents/overlay/ML-auto-baseball-pitching-overlay/env-MLauto/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /var/folders/vx/5x_d29f50t7387_bmsjsc8700000gn/T/tmp8cv3k60q Check the logs for full command output.
WARNING: You are using pip version 19.2.3, however version 22.0.4 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
(env-MLauto) MacBook-Pro-2:ML-auto-baseball-pitching-overlay jardik$ `

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.