Width.ai

Ai Automated Ball Tracking for Players and Coaches of Golf, Soccer, Cricket, and More

Karthik Shiraly
·
August 16, 2022

If you play any sports that involve a ball — soccer, football, golf, basketball, tennis, cricket, rugby, and more — you’ll be happy to know that artificial intelligence (AI) can help you systematically enhance your technique and grow as a player. Or if you’re a coach, AI can assist you to become more effective.

So, where can you apply AI in your favorite sport? You can use it to observe and analyze any aspect of any sport. But to help you understand its capabilities better, we’ll focus on one feature that’s useful across multiple sports — automated ball tracking.

What Is Ball Tracking in Sports?

Ball tracking records a ball's 3D position, and sometimes other attributes like speed or spin, relative to the field (or court) and the players.

By doing so, players and coaches can analyze their techniques and improve on them. Referees and umpires can give better decisions. Broadcasters like TV and YouTube sports channels can offer insights to their viewers through engrossing visualizations.

Computer Vision and Deep Learning for Automated Ball Tracking

Recent advances in AI, especially the use of deep learning and deep neural networks for computer vision tasks, enable us to reliably automate ball tracking. In addition, other useful tasks like player detection, player tracking, body parts segmentation, pose estimation, and activity recognition can be combined with ball tracking to provide comprehensive insights and analysis for any sport.

In the next sections, we’ll explore ball tracking in golf, soccer, and cricket to understand AI’s benefits.

Automated Ball Tracking in Golf

automated ball tracking in golf with swing analysis

The National Golf Foundation says 2.4-3.2 million Americans per year play golf for the first time. But only about 27% of them turn into regular players. There is a huge demand for coaching and self-teaching aids that AI can help fulfill.

Help Players Improve Their Skills

If you play golf at any level, you already know that it’s a highly technical game. An unending number of factors can affect your shot — your pose and height, the swing arc, the speed and angle of approach, the type of the golf club, the club loft (angle of the club face), the materials of the club and the ball, the grass, changes in ground elevations, even the wind.

Getting good at golf can be frustrating. But being a game over which people socialize and make business deals, many players are highly motivated to get better.

This is where AI can help. Automated golf ball tracking apps let you analyze your technique and improve at your own pace. In addition to automated ball tracking, these apps combine pose estimation, swing tracking, and other analysis to address every aspect of your play.

Golf Ball Tracking Technology Under the Hood

TrackNet Architecture (Source: Huang et al.)

A smartphone or a laptop is placed on a tripod about 5 feet behind the player. This position allows it to track the ball from the moment it’s launched till it hits the ground.

Most players like to review the trajectory immediately after the shot. So, real-time ball detection and tracking are essential. For high-speed golf ball detection and localization in real-time, we use a mobile-friendly lightweight object detection model like YOLOv3. YOLO reports a bounding box for the ball in the input image and a confidence score for the detection. But instead of using it to detect the ball every frame, we optimize by using it only every few frames. For the gaps, we use a faster image processing algorithm like the Kalman or particle filter.

Being such a technical game, many determined players also like to analyze their play off-course. For this, more accurate detection and object tracking are necessary. They may need a more accurate 3D trajectory by combining inputs from a second camera. For such off-course analysis, we recommend using more sophisticated models like TrackNet and TrackNetv2. They detect the ball more accurately by analyzing sequences of images.

Assist Golf Coaches

If you’re a golf coach, AI can help you become more effective by enabling you to analyze, measure metrics, and visualize all aspects of your students’ techniques. Combining ball tracking with activity recognition, pose estimation, swing tracking, and data science algorithms like clustering gives you comprehensive insights into techniques and weaknesses.

Each of these tasks uses its own dedicated deep learning model. For activity recognition and pose estimation, we use pre-trained out-of-the-box body segmentation models from frameworks like Detectron2.

Simulate Swings, Stances, and Golf Clubs

Ball and swing tracking are pretty useful by themselves. But even more useful would be the ability to simulate all the factors involved in a golf shot, vary them, and choose the ones that improve the shot. 

For example, you can vary the positions and angles of your simulated arms and see how the shot improves. You can then practice this new position out on the course.

Automated Ball Tracking for Golf Simulation

For this to work, we create a realistic simulation model that includes all the factors that influence a golf shot. But instead of modeling them explicitly using formulas, we use machine learning to learn all the complex inter-relationships between these factors. The input training data for this learning includes:

  • Data from activity recognition and pose estimation
  • Ball 3D trajectory from automatic ball tracking
  • Material and dimensions of the golf club
  • The trajectory of the golf club, using swing tracking
  • Local wind and weather factors
  • In-flight golf ball detection
  • Ball movements and rotation analysis
Pose Estimation in Golf

By combining these factors, the simulator learns to predict a ball’s trajectory when given all the other factors. We don’t explicitly model its physics using formulas. Instead, all the physics phenomena are embedded in the parameters of the model by simply learning from the training data.

Automated Ball Tracking in Soccer

Soccer (or football) is a very popular sport worldwide, especially in Europe, Latin America, and Africa. The sport’s ecosystem includes football clubs, coaching academies, educational institutions, and broadcast media. Let’s see how AI and particularly ball tracking systems are used in soccer.

Improve Player and Goalkeeper Skills

If you’re a soccer player, automated ball tracking can help you improve your ball control and passing skills. It enables you to visualize how the ball moves in response to your leg and feet movements. You can discover weaknesses in your technique and improve upon them.

How Soccer Ball Tracking Works

DeepSort to track objects in a video stream

Unlike golf or cricket, in soccer, the ball is always moving with several players running around it. It’s a fast-paced game played in a large field which means the cameras have to pan around the field a lot. So, a capable ball tracking system has to overcome challenges like motion blur and frequent occlusion.

We use a sports video analysis pipeline that includes optical flow to compensate for motion blur, a fast detector like YOLOv3 or YOLOv4 for ball detection, and the unscented Kalman filter to continue tracking accurately even when the ball is blocked by players’ bodies and legs.

Since the YOLO models are general-purpose object detectors, we improve their accuracy by fine-tuning them for a specific sport. For example, we fine-tune them on a dataset of soccer ball images in their typical surroundings to help the model learn to detect soccer balls more accurately.

Help Coaches Analyze Positional Play and Tactics

Automated ball tracking also helps soccer coaches record, analyze, and visualize strategies and tactics like positional play, attack, and defense. For this, we combine ball tracking with deep learning models for player detection and tracking. Multiple cameras are fixed around the periphery of the field.

player tracking with SORT algorithm in soccer
Tracking players via SORT

Compared to commercial systems like Hawk-Eye, our custom systems are built for your specific use case allowing us to get a scorching hot in-domain accuracy.

Automated Ball Tracking in Cricket

batter playing cricket

Cricket is a popular sport in the Commonwealth countries. Its ecosystem includes cricket boards, coaching academies, educational institutions, and broadcast media. Let’s explore how AI and ball tracking are used in cricket.

Assist Coaches in Analyzing Bowling, Batting, and Field Placement

Let’s see how coaches can analyze and enhance a cricketer’s skills using AI.

Learning Tactics and Patterns

Good cricket tactics are all about playing mind games against your opponents. Surprise them to keep them unbalanced and on edge.

A bowler seeks to lull the batter by starting out predictably before hitting them with an unexpected swing or googly. Meanwhile, the batter constantly scans the field for weak points to send the ball to and score a quick run or a boundary. Gaps in the field, slow runners, and clumsy fielders are all targets for a clever batter.

As a coach in an academy or an institution, teaching a player to notice such patterns of play and weak points — both their own and those of their opponents — is an important goal of cricket coaching. Every player is taught to unlearn their predictability, get out of their comfort zone occasionally, and surprise their opponents.

Visualizing Patterns of Play

Visualizing different aspects of play over time helps your players discover patterns of play and weak points like:

  • Where is a bowler pitching most of the time? At what speeds? What’s the typical curve of their ball?
  • How is a batter moving at the crease? What’s their typical stance? Which is their dominant or weak side when they hit a ball? At what height do their bats tend to meet the balls?
  • Is a particular fielder weaker on their left side or right? How good are they at jumping and catching?

AI helps with such visualizations using automated ball tracking and pitch detection. The data are shown as heat maps, pitch maps, “wagon wheel” graphs (that show trajectories of all the shots played by a batter), and other types of visualizations.

Ball Tracking and Pitch Detection Using AI

As a coach, you’d like to give immediate feedback on bowling or batting actions while out practicing. But you also require more detailed analyses and visualizations post-practice. Both capabilities are needed in a good ball tracking solution.

In the typical coaching setting, a smartphone, or a laptop with an off-the-shelf camera, is placed near the stumps at the non-striker’s end looking down the pitch. A second device may be placed to the side to capture bowling or batting actions from the side. They record the videos for the AI models to process.

Real-Time Tracking

object detection in cricket to recognize various objects such as bats and players
Object detection system for cricket that can integrate with ball tracking technology

For quick ball detection in real-time, we use an object detector like YOLOv3 or YOLOv4. It’s lightweight, mobile-friendly, and fast with high frames-per-second. These object detector systems make it easy to track multiple balls as well in the same instance.

But detection in every frame is unnecessary because a cricket ball travels quite predictably, not randomly, between two frames. So, we opt for a more lightweight tracking approach using probabilistic tracking algorithms like the Kalman or particle filter. They predict the position of a ball based on its previous position.

But an additional complication in cricket is the ball pitching on the ground. A cricket ball’s pitching makes its trajectory nonlinear. To handle that, we use the unscented variant of the Kalman filter. It can predict the position of the ball, in 2D or 3D, from its previous position. When there’s a sudden flip in the vertical direction of the ball, we know that it has pitched on the ground.

Post-Practice Analysis

For post-practice analysis, we suggest a more capable detection algorithm like TrackNet or TrackNetv2. They detect balls more accurately by examining sequences of images.

Help Umpires Make Better Decisions

team playing cricket with an umpire in the front

Cricket has some unique rules that require an umpire to imagine a what-if situation before giving a decision. For example, the leg before wicket (LBW) rule says that if a batter defends a ball with their pad, the umpire should mentally trace the trajectory of the ball as if the leg wasn’t present and if that imaginary path looks like it will hit the stumps, then declare the batter out. 

Unsurprisingly, such subjective judgments based on imagination have led to a lot of controversial decisions over the years. The situation was improved by automated decision review systems like Hawk-Eye. However, these systems are cost-prohibitive and used only in top-tier matches. 

Less expensive AI ball tracking systems can be immensely beneficial for county-level and local matches that don’t have large budgets. Our automated cricket ball tracking uses off-the-shelf devices to supply intelligent ball tracking solutions to any local coaching academy, institution, or cricket board.

Automated Ball Tracking for Umpiring

For this use case, off-the-shelf cameras are typically attached around the periphery of the field. The ball tracking solution system takes in video feeds from multiple cameras and runs the ball detector on each. We again use an unscented Kalman filter for tracking because there are nonlinear direction changes.

Next, the pipeline uses multi-view geometry to combine multiple camera views into a 3D projection and calculate the 3D position of the ball. Trained on lots of videos of ball movement, the system is now able to predict the 3D trajectory of the ball using a regression model. A second regression-classification model, fine-tuned on a dataset of LBW videos, detects LBW and reports a confidence score.

AI Is a Game Changer for Sports

AI’s human-like vision, language, and audio understanding capabilities enable it to be very useful for multiple tasks in every sport’s ecosystem, including player self-teaching, coaching, officiating, and broadcasting. Moreover, these improvements are now available cheaply to every stratum of society and level of competition, thus directly contributing to socio-economic improvements in the lives of people through sports.

With our deep expertise in AI, deep learning, and computer vision, Width.ai is the ideal implementation partner to bring your sports improvement ideas to life. Let’s talk!

References

  • Yu-Chuan Huang, I-No Liao, Ching-Hsuan Chen, Tsì-Uí İk, Wen-Chih Peng. "TrackNet: A Deep Learning Network for Tracking High-speed and Tiny Objects in Sports Applications". arXiv:1907.03698 [cs.LG]. https://arxiv.org/abs/1907.03698