NYC Data Science Academy| Blog
Bootcamps
Lifetime Job Support Available Financing Available
Bootcamps
Data Science with Machine Learning Flagship ๐Ÿ† Data Analytics Bootcamp Artificial Intelligence Bootcamp New Release ๐ŸŽ‰
Free Lesson
Intro to Data Science New Release ๐ŸŽ‰
Find Inspiration
Find Alumni with Similar Background
Job Outlook
Occupational Outlook Graduate Outcomes Must See ๐Ÿ”ฅ
Alumni
Success Stories Testimonials Alumni Directory Alumni Exclusive Study Program
Courses
View Bundled Courses
Financing Available
Bootcamp Prep Popular ๐Ÿ”ฅ Data Science Mastery Data Science Launchpad with Python View AI Courses Generative AI for Everyone New ๐ŸŽ‰ Generative AI for Finance New ๐ŸŽ‰ Generative AI for Marketing New ๐ŸŽ‰
Bundle Up
Learn More and Save More
Combination of data science courses.
View Data Science Courses
Beginner
Introductory Python
Intermediate
Data Science Python: Data Analysis and Visualization Popular ๐Ÿ”ฅ Data Science R: Data Analysis and Visualization
Advanced
Data Science Python: Machine Learning Popular ๐Ÿ”ฅ Data Science R: Machine Learning Designing and Implementing Production MLOps New ๐ŸŽ‰ Natural Language Processing for Production (NLP) New ๐ŸŽ‰
Find Inspiration
Get Course Recommendation Must Try ๐Ÿ’Ž An Ultimate Guide to Become a Data Scientist
For Companies
For Companies
Corporate Offerings Hiring Partners Candidate Portfolio Hire Our Graduates
Students Work
Students Work
All Posts Capstone Data Visualization Machine Learning Python Projects R Projects
Tutorials
About
About
About Us Accreditation Contact Us Join Us FAQ Webinars Subscription An Ultimate Guide to
Become a Data Scientist
    Login
NYC Data Science Acedemy
Bootcamps
Courses
Students Work
About
Bootcamps
Bootcamps
Data Science with Machine Learning Flagship
Data Analytics Bootcamp
Artificial Intelligence Bootcamp New Release ๐ŸŽ‰
Free Lessons
Intro to Data Science New Release ๐ŸŽ‰
Find Inspiration
Find Alumni with Similar Background
Job Outlook
Occupational Outlook
Graduate Outcomes Must See ๐Ÿ”ฅ
Alumni
Success Stories
Testimonials
Alumni Directory
Alumni Exclusive Study Program
Courses
Bundles
financing available
View All Bundles
Bootcamp Prep
Data Science Mastery
Data Science Launchpad with Python NEW!
View AI Courses
Generative AI for Everyone
Generative AI for Finance
Generative AI for Marketing
View Data Science Courses
View All Professional Development Courses
Beginner
Introductory Python
Intermediate
Python: Data Analysis and Visualization
R: Data Analysis and Visualization
Advanced
Python: Machine Learning
R: Machine Learning
Designing and Implementing Production MLOps
Natural Language Processing for Production (NLP)
For Companies
Corporate Offerings
Hiring Partners
Candidate Portfolio
Hire Our Graduates
Students Work
All Posts
Capstone
Data Visualization
Machine Learning
Python Projects
R Projects
About
Accreditation
About Us
Contact Us
Join Us
FAQ
Webinars
Subscription
An Ultimate Guide to Become a Data Scientist
Tutorials
Data Analytics
  • Learn Pandas
  • Learn NumPy
  • Learn SciPy
  • Learn Matplotlib
Machine Learning
  • Boosting
  • Random Forest
  • Linear Regression
  • Decision Tree
  • PCA
Interview by Companies
  • JPMC
  • Google
  • Facebook
Artificial Intelligence
  • Learn Generative AI
  • Learn ChatGPT-3.5
  • Learn ChatGPT-4
  • Learn Google Bard
Coding
  • Learn Python
  • Learn SQL
  • Learn MySQL
  • Learn NoSQL
  • Learn PySpark
  • Learn PyTorch
Interview Questions
  • Python Hard
  • R Easy
  • R Hard
  • SQL Easy
  • SQL Hard
  • Python Easy
Data Science Blog > Student Works > Game Analysis With Object Tracking

Game Analysis With Object Tracking

Roger Liu
Posted on Jun 24, 2024

Object Tracking with Python Vision for Soccer Analysis 

Introduction

This is not your fatherโ€™s ball game. The ability to accurately and efficiently track objects, such as athletes, balls, and equipment, has revolutionized how sports are analyzed, broadcasted, and understood. In sports, object tracking technology enhances the viewing experience by providing real-time data and analytics that aids coaches and players in performance analysis and enables them to make better decision.s. Analyzing sports footage using a program with vision capabilities offers several compelling advantages that can significantly enhance both performance and understanding within the realm of sports. Some benefits it may include:

  1. Performance Improvement: A vision-based program can provide detailed, objective analysis of players' movements, techniques, and tactics. Coaches and athletes can use this data to identify strengths, weaknesses, and areas for improvement. For instance, analyzing the biomechanics of a tennis player's serve or a soccer player's dribbling technique can pinpoint inefficiencies that could be optimized through targeted training.
  2. Tactical Insights: Beyond individual performance, vision-based analysis can capture the dynamics of team play. It can track player positioning, movement patterns, and interactions during a game. This data is invaluable for coaches in planning team formations, assessing defensive and offensive strategies, and making informed tactical adjustments during matches.
  3. Objective Evaluation: Human perception can be limited and subjective. A program with vision provides an objective evaluation of various metrics, including speed, distance covered, ball trajectory, and reaction times. This objective data enhances the precision of performance assessments and reduces biases that might influence human observations.
  4. Real-Time Feedback: In competitive sports, real-time feedback is crucial for immediate adjustments. A vision-based program can analyze footage as it happens, providing instant insights into performance metrics. This allows coaches and players to make rapid decisions and corrections during training sessions or matches.
  5. Scouting and Recruitment: Vision-based analysis is also of great value for identifying talent identification and recruiting. . It allows scouts and recruiters to evaluate prospective players based on objective performance metrics and tactical acumen, supplementing traditional scouting methods with data-driven insights.

I developed a model using the YOLOv5. It takes a raw video as an input and outputs an mp4 file that  identifies all the players, referees, and ball movements. It also tracks relevant   player statistics  like player movement speed and player distance moved. Although YOLOv8 is more advanced than  YOLOv5, the earlier version has been found to be more accurate and better at object detection than YOLOv8. YOLOv9 and 10 are still in development and are not stable. The YOLO models are unique because they use a state of the art methodology of detecting objects. I used these libraries to create the model. 

  1. Ultralytics
  2. Opencv
  3. Numpy
  4. Pandas
  5. Supervision

YOLO Model Timeline

The YOLO model, introduced by Joseph Redmon et al. in 2015, revolutionized real-time object detection. The first version, YOLOv1, offered a unified approach by framing object detection as a single regression problem, directly predicting bounding boxes and class probabilities from full images. The YOLO model has ten iterations. They are as follows:

YOLOv1 (2015)

Design: YOLOv1 divides the input image into an SS grid. Each grid cell predicts bounding boxes, confidence scores, and class probabilities.

Advantages: Achieved real-time performance with 45 frames per second (fps) on a PASCAL VOC dataset, demonstrating that a single convolutional neural network (CNN) could effectively perform object detection.

YOLOv2 (2016) and YOLOv3 (2018)

YOLOv2: Also known as YOLO9000,  this version improved upon YOLOv1 by introducing batch normalization, high-resolution classifier, anchor boxes, and multi-scale training. It could detect over 9000 object categories.

YOLOv3: Further enhanced accuracy and speed with a more sophisticated network, utilizing residual blocks, feature pyramid networks (FPN), and three different scales for detecting objects of varying sizes.

YOLOv4 and Beyond (2020 - Present)

YOLOv4: Introduced by Alexey Bochkovskiy et al., this iteration incorporated additional techniques like Cross Stage Partial connections (CSP), Mish activation function, and a new data augmentation technique called Mosaic.

YOLOv5: Developed by Ultralytics, it focuses on user-friendly implementation, providing pretrained models and easy-to-use scripts.

YOLOv6, YOLOv7, and YOLOv8: Continued advancements, each iteration aiming for better performance metrics (speed and accuracy) and ease of deployment in various applications. YOLOv8 was also developed by Ultralytics

YOLOv9:introduces innovative methods like Programmable Gradient Information (PGI) and the Generalized Efficient Layer Aggregation Network (GELAN).

YOLOv10: is created by researchers from Tsinghua University using the Ultralytics Python package. This version introduces real-time object detection advancements by introducing an End-to-End head that eliminates Non-Maximum Suppression (NMS) requirements.

Model and Libraries

Input

The input into this model is an mp4 file. However, other file types can also work as an input.

Base Model

The image above shows  the output for the base YOLOv5 model on the input video. Its output consists of three main items: the bounding box, object label, and confidence of the label. Notice that people on the sideline are also detected in the model. That bit of  unnecessary detail creates noise for the model, which is not a good thing. Also note that the confidence the model has in each of its labels is not high. Finally, although not showcased in this photo, the ball is oftentimes lost in tracking. 

Trained Model

After the model was trained using Roboflowโ€™s training data and Google Colabโ€™s virtual GPUโ€™s. Here we see that the confidence of each of the labels is higher. Also the people on the sideline are not detected anymore, and the object labels are changed from โ€œpersonโ€ to โ€œplayerโ€. However, the issue of losing the ball detection still persists.

More User Friendly Model

To address those issues, I  changed the labels and bounding box representations to clear out visual noise and make the model easier to interpret. Only visual changes are made in the model in this step. The ball icon is also a green triangle. However, as seen in the picture, the ball is sometimes not detected. 

Model with Team Colors

To add team colors to the model, I took the bounding box of each of the detected objects. I then took the top half of the bounding box โ€“ where the kit is located โ€“ and ran a K-Means model. I found the average RGB value of the two clusters and took the K-Means label of the 4 corners of the image to find the background label according to the K-Means model. 

Top half of bounding box

2 Clusters K-Means model found

Model with Interpolated Ball

In this model, the issue with losing ball detection is solved. Because passes in soccer are linear or have a path, we can interpolate where the ball should be in the frames where the detection is lost. If we take the last frame where the ball is detected and the first frame where the ball is relocated, we can estimate the position of the ball based on the frames. This solves the issue of losing ball detection. 

Model showing Ball Possession 

I then added a red icon showing which player has possession of the ball. We are able to do this because we have the ball position and player position. If the ball is close enough to a player, we can say they have possession.   

Model with Team Possession Statistic

Because we have player possession and know which player is on which team, we can calculate the overall team possession in the clip. I added a statistics panel to the bottom right corner to show each teamโ€™s possession. 

Model with Camera Shift and Position Adjusted 

Due to the camera angle and shift, calculating player speed and distance traveled will need a transformation or scaling. This is seen because the number of pixels between player 3 on the green team and the top of the soccer pitch is not equal to the number of pixels between player 3 on the green team and the bottom of the soccer pitch. If we have a point of reference, we can adjust each playerโ€™s position accordingly. There is no visual change in this model output, but the positions of each of the bounding boxes are adjusted. Due to the camera shift, having points of reference is difficult, but we can track the adjusted positions for players in the middle third of the soccer field. 

Model with Speed and Distance Calculations

Now with the position adjusted, we can estimate the playerโ€™s speed and distance traveled. It is displayed under each player in the tracked region. 

Further Works

To further improve this model. we can add matches to the training data. This would sharpen the model and may even solve the problem of losing ball detection with no added work. Interpolation of the ball and adjusted positions of the players may also be improved. A closer estimation can be found and used in the model. 

Because we have individual players, we can also keep statistics on individual players. To further this project, the ability to track players throughout the season can be added, provided we have a universal library of all players in the league. 

This model takes a raw soccer video as an input and outputs a soccer video with players, referees, and ball tracked with statistics. This can be expanded into other sports, as well, including basketball, tennis, football, baseball, rugby, cricket etc. There are many insights a program or model such as this may show a coach that were not seen before. 

About Author

Roger Liu

I graduated from Cornell University in 2022 with a B.S in Information Science, Systems, and Technology from the College of Engineering with concentrations in Data Science and Networks, Crowds, and Markets
View all posts by Roger Liu >

Leave a Comment

No comments found.

View Posts by Categories

All Posts 2399 posts
AI 7 posts
AI Agent 2 posts
AI-based hotel recommendation 1 posts
AIForGood 1 posts
Alumni 60 posts
Animated Maps 1 posts
APIs 41 posts
Artificial Intelligence 2 posts
Artificial Intelligence 2 posts
AWS 13 posts
Banking 1 posts
Big Data 50 posts
Branch Analysis 1 posts
Capstone 206 posts
Career Education 7 posts
CLIP 1 posts
Community 72 posts
Congestion Zone 1 posts
Content Recommendation 1 posts
Cosine SImilarity 1 posts
Data Analysis 5 posts
Data Engineering 1 posts
Data Engineering 3 posts
Data Science 7 posts
Data Science News and Sharing 73 posts
Data Visualization 324 posts
Events 5 posts
Featured 37 posts
Function calling 1 posts
FutureTech 1 posts
Generative AI 5 posts
Hadoop 13 posts
Image Classification 1 posts
Innovation 2 posts
Kmeans Cluster 1 posts
LLM 6 posts
Machine Learning 364 posts
Marketing 1 posts
Meetup 144 posts
MLOPs 1 posts
Model Deployment 1 posts
Nagamas69 1 posts
NLP 1 posts
OpenAI 5 posts
OpenNYC Data 1 posts
pySpark 1 posts
Python 16 posts
Python 458 posts
Python data analysis 4 posts
Python Shiny 2 posts
R 404 posts
R Data Analysis 1 posts
R Shiny 560 posts
R Visualization 445 posts
RAG 1 posts
RoBERTa 1 posts
semantic rearch 2 posts
Spark 17 posts
SQL 1 posts
Streamlit 2 posts
Student Works 1687 posts
Tableau 12 posts
TensorFlow 3 posts
Traffic 1 posts
User Preference Modeling 1 posts
Vector database 2 posts
Web Scraping 483 posts
wukong138 1 posts

Our Recent Popular Posts

AI 4 AI: ChatGPT Unifies My Blog Posts
by Vinod Chugani
Dec 18, 2022
Meet Your Machine Learning Mentors: Kyle Gallatin
by Vivian Zhang
Nov 4, 2020
NICU Admissions and CCHD: Predicting Based on Data Analysis
by Paul Lee, Aron Berke, Bee Kim, Bettina Meier and Ira Villar
Jan 7, 2020

View Posts by Tags

#python #trainwithnycdsa 2019 2020 Revenue 3-points agriculture air quality airbnb airline alcohol Alex Baransky algorithm alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus ames dataset ames housing dataset apartment rent API Application artist aws bank loans beautiful soup Best Bootcamp Best Data Science 2019 Best Data Science Bootcamp Best Data Science Bootcamp 2020 Best Ranked Big Data Book Launch Book-Signing bootcamp Bootcamp Alumni Bootcamp Prep boston safety Bundles cake recipe California Cancer Research capstone car price Career Career Day ChatGPT citibike classic cars classpass clustering Coding Course Demo Course Report covid 19 credit credit card crime frequency crops D3.js data data analysis Data Analyst data analytics data for tripadvisor reviews data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization database Deep Learning Demo Day Discount disney dplyr drug data e-commerce economy employee employee burnout employer networking environment feature engineering Finance Financial Data Science fitness studio Flask flight delay football gbm Get Hired ggplot2 googleVis H20 Hadoop hallmark holiday movie happiness healthcare frauds higgs boson Hiring hiring partner events Hiring Partners hotels housing housing data housing predictions housing price hy-vee Income industry Industry Experts Injuries Instructor Blog Instructor Interview insurance italki Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter las vegas airport lasso regression Lead Data Scienctist Lead Data Scientist leaflet league linear regression Logistic Regression machine learning Maps market matplotlib Medical Research Meet the team meetup methal health miami beach movie music Napoli NBA netflix Networking neural network Neural networks New Courses NHL nlp NYC NYC Data Science nyc data science academy NYC Open Data nyc property NYCDSA NYCDSA Alumni Online Online Bootcamp Online Training Open Data painter pandas Part-time performance phoenix pollutants Portfolio Development precision measurement prediction Prework Programming public safety PwC python Python Data Analysis python machine learning python scrapy python web scraping python webscraping Python Workshop R R Data Analysis R language R Programming R Shiny r studio R Visualization R Workshop R-bloggers random forest Ranking recommendation recommendation system regression Remote remote data science bootcamp Scrapy scrapy visualization seaborn seafood type Selenium sentiment analysis sentiment classification Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau teachers team team performance TensorFlow Testimonial tf-idf Top Data Science Bootcamp Top manufacturing companies Transfers tweets twitter videos visualization wallstreet wallstreetbets web scraping Weekend Course What to expect whiskey whiskeyadvocate wildfire word cloud word2vec XGBoost yelp youtube trending ZORI

NYC Data Science Academy

NYC Data Science Academy teaches data science, trains companies and their employees to better profit from data, excels at big data project consulting, and connects trained Data Scientists to our industry.

NYC Data Science Academy is licensed by New York State Education Department.

Get detailed curriculum information about our
amazing bootcamp!

Please enter a valid email address
Sign up completed. Thank you!

Offerings

  • HOME
  • DATA SCIENCE BOOTCAMP
  • ONLINE DATA SCIENCE BOOTCAMP
  • Professional Development Courses
  • CORPORATE OFFERINGS
  • HIRING PARTNERS
  • About

  • About Us
  • Alumni
  • Blog
  • FAQ
  • Contact Us
  • Refund Policy
  • Join Us
  • SOCIAL MEDIA

    ยฉ 2025 NYC Data Science Academy
    All rights reserved. | Site Map
    Privacy Policy | Terms of Service
    Bootcamp Application