<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Dmitrii Sadovnik</title>
    <description>The latest articles on DEV Community by Dmitrii Sadovnik (@performstars).</description>
    <link>https://dev.to/performstars</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F4212798%2F6acc3317-f27f-4896-853a-6675881a25d8.png</url>
      <title>DEV Community: Dmitrii Sadovnik</title>
      <link>https://dev.to/performstars</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/performstars"/>
    <language>en</language>
    <item>
      <title>Teaching a Computer to Understand Billiards: From Ball Detection to Trajectory Reconstruction</title>
      <dc:creator>Dmitrii Sadovnik</dc:creator>
      <pubDate>Wed, 28 Oct 2026 10:29:32 +0000</pubDate>
      <link>https://dev.to/performstars/teaching-a-computer-to-understand-billiards-from-ball-detection-to-trajectory-reconstruction-32j5</link>
      <guid>https://dev.to/performstars/teaching-a-computer-to-understand-billiards-from-ball-detection-to-trajectory-reconstruction-32j5</guid>
      <description>&lt;p&gt;&lt;em&gt;Computer vision, YOLO, geometry, and physics-based modeling in PerformStars&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ft5pbljwcrmfdj4r3rtc5.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Ft5pbljwcrmfdj4r3rtc5.jpg" alt=" " width="451" height="451"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At first glance, automated billiards analysis seems like a relatively straightforward computer vision task. The table has known geometry, the balls are spherical, and their number and size are constrained by the rules of the game.&lt;/p&gt;

&lt;p&gt;Place a camera over the table, detect the balls in each frame, and track their motion. In practice, however, the problem is considerably more complex.&lt;/p&gt;

&lt;p&gt;Balls can move rapidly, collide with one another and with the cushions, temporarily occlude each other, disappear from the image, or become difficult to distinguish under varying lighting conditions. The camera can be positioned at an angle, introducing perspective distortion.&lt;/p&gt;

&lt;p&gt;Detecting a ball is only the beginning. To analyze a shot, the system must determine which physical ball is moving, where it was before the shot, how its trajectory evolves, and what ultimately happened.&lt;/p&gt;

&lt;p&gt;At &lt;strong&gt;PerformStars&lt;/strong&gt;, we are developing a system that turns ordinary footage of billiards games and practice sessions into structured spatial and temporal data.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Why Detecting Billiard Balls Is Harder Than It Looks
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fimrs8vzzq1jmz9fb0ut8.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fimrs8vzzq1jmz9fb0ut8.jpg" alt=" " width="200" height="200"&gt;&lt;/a&gt;&lt;br&gt;
Modern neural-network detectors perform well on many objects with distinct visual features. Billiards presents a different set of challenges.&lt;/p&gt;

&lt;p&gt;First, the balls occupy only a small fraction of the image. When an entire table is filmed in Full HD, a ball may be just a few dozen pixels across.&lt;/p&gt;

&lt;p&gt;Second, balls have nearly identical shapes and sizes, while their appearance varies with the illumination.&lt;/p&gt;

&lt;p&gt;Third, reflections, highlights, and shadows may affect how precisely the center of a ball can be located.&lt;/p&gt;

&lt;p&gt;Motion blur creates another problem. At a speed of 2 m/s and a frame rate of 30 fps, a ball travels approximately &lt;strong&gt;6.7 cm between consecutive frames&lt;/strong&gt;. That is more than the diameter of a standard pool ball, &lt;strong&gt;57.15 mm&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;As a result, correctly detecting objects in successive frames does not guarantee that we can correctly match them. When multiple balls collide, the nearest detection in the next frame may belong to a different ball.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Ball Detection with YOLO
&lt;/h2&gt;

&lt;p&gt;PerformStars uses &lt;strong&gt;custom-trained models from the YOLO family&lt;/strong&gt; to detect billiard balls. This approach offers a practical balance between inference speed and the localization of small objects.&lt;/p&gt;

&lt;p&gt;A detector processes a video frame and returns object locations, bounding-box dimensions, and confidence scores. The estimated centers of these detections become inputs to subsequent geometric analysis.&lt;/p&gt;

&lt;p&gt;A single universal detector, however, is not enough for every recording. Cue-sport disciplines, ball designs, lighting conditions, and viewing angles differ. The project therefore uses specialized models and training datasets for different object types and recording conditions.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why a Neural Network Alone Is Not Enough
&lt;/h3&gt;

&lt;p&gt;A detector answers the question: &lt;em&gt;“Where are the balls in this frame?”&lt;/em&gt; It does not inherently know which ball moved a moment ago, which one took part in a collision, or where a particular ball should appear next. That requires reasoning across a sequence of frames rather than treating images independently.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Table Geometry and Real-World Coordinates
&lt;/h2&gt;

&lt;p&gt;Image coordinates depend on camera placement. The same physical point on the table can have very different pixel coordinates in overhead and angled footage. To reason about motion, we need a consistent coordinate system attached to the table.&lt;/p&gt;

&lt;p&gt;PerformStars uses table-surface segmentation and geometric calibration. One of the main mathematical tools is a &lt;strong&gt;projective transformation&lt;/strong&gt;, also known as a &lt;strong&gt;homography&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzcopdck62nximg7kf98q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fzcopdck62nximg7kf98q.png" alt=" " width="621" height="155"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Equation 1.&lt;/strong&gt; Projective mapping between image coordinates &lt;em&gt;(x, y)&lt;/em&gt; and coordinates &lt;em&gt;(X, Y)&lt;/em&gt; on the table plane. &lt;em&gt;H&lt;/em&gt; is the transformation matrix, and λ is the scale factor in homogeneous coordinates.&lt;/p&gt;

&lt;p&gt;After calibration, ball locations can be compared in a shared coordinate system, and distances and angles can be estimated independently of the original camera viewpoint. Accuracy still depends on how well the table is localized and calibrated: a homography cannot eliminate all detection errors.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. From Independent Detections to Trajectories
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fp1zalu9xbrt4kzimyu0r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fp1zalu9xbrt4kzimyu0r.png" alt=" " width="799" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Suppose a detector identifies ten balls in one frame and ten in the next. Which detection corresponds to which physical ball?&lt;/p&gt;

&lt;p&gt;The simplest method is to match objects using the distance between their centers:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flvyu2ptogonbkw1uu8d6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Flvyu2ptogonbkw1uu8d6.png" alt=" " width="584" height="80"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Equation 2.&lt;/strong&gt; Euclidean distance between two detected positions in the table coordinate system.&lt;/p&gt;

&lt;p&gt;This method is reliable only when displacement is relatively small and the scene is unambiguous. A fast-moving ball may travel farther than its distance to a neighboring ball. During collisions, trajectories converge and detections can become difficult to distinguish.&lt;/p&gt;

&lt;p&gt;Nearest-neighbor matching therefore needs additional safeguards. In PerformStars, detections are treated as time-dependent observations of physical objects. The analysis considers spatial proximity, displacement between frames, the geometry of the playing surface, and whether the inferred motion is consistent over time.&lt;/p&gt;

&lt;p&gt;It is especially important to recover from temporary detection loss. A ball may disappear for several frames because of blur or occlusion without the underlying shot actually ending.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Ball Number Recognition and Identity Tracking
&lt;/h2&gt;

&lt;p&gt;In pool, balls have different colors and markings, but recognizing a specific ball is sensitive to rotation, lighting, reflections, and image resolution.&lt;/p&gt;

&lt;p&gt;PerformStars explores and uses specialized classifiers trained on cropped images of individual balls. Once a ball is detected, its image region can be passed to a classifier that estimates probabilities for possible identities.&lt;/p&gt;

&lt;p&gt;Rather than relying on a single frame, the system can aggregate classification evidence across multiple observations. But this strategy is only useful while we are confident that those observations refer to the same physical ball.&lt;/p&gt;

&lt;p&gt;If a tracking algorithm swaps two identities during a collision, previously accumulated evidence becomes attached to the wrong object. &lt;strong&gt;Ball-number recognition and multi-object tracking are therefore tightly connected problems.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Physics as an Additional Source of Evidence
&lt;/h2&gt;

&lt;p&gt;Billiards is particularly interesting because ball motion follows reasonably well-understood mechanical principles. The principal interactions include motion across the cloth, ball-to-ball collisions, cushion impacts, and deceleration due to friction.&lt;/p&gt;

&lt;p&gt;This makes physical simulation a useful tool for interpreting ambiguous trajectories. PerformStars complements motion analysis with simulations of plausible shot scenarios.&lt;/p&gt;

&lt;p&gt;The general idea can be expressed as an optimization problem: find the model parameters that minimize the disagreement between observed and simulated positions.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fv7z9edh0asumdvaa9bih.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fv7z9edh0asumdvaa9bih.png" alt=" " width="705" height="100"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Equation 3.&lt;/strong&gt; Selecting physical-model parameters θ to best match simulated positions to observations. This is an illustrative mathematical formulation, &lt;strong&gt;not the complete objective function used by the production system&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;A real implementation must also account for detection uncertainty, ambiguous ball assignments, incomplete trajectories, and interactions among multiple balls.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. How Do We Know a Shot Has Happened?
&lt;/h2&gt;

&lt;p&gt;A further challenge is dividing continuous video into individual shots. The system must identify the start of a shot, follow the movement and collisions, and establish when the episode has finished.&lt;/p&gt;

&lt;p&gt;If an episode is terminated too early, residual ball movement may be incorrectly interpreted as the beginning of another shot.&lt;/p&gt;

&lt;p&gt;For that reason, determining whether the table is at rest involves analyzing positional changes over a time interval, not making a decision from one frame. Requiring several consecutive confirmations helps reduce the impact of noise and brief detection gaps.&lt;/p&gt;

&lt;p&gt;Once shot boundaries have been established, the system can reconstruct the initial layout, motion parameters, and outcome. This is the stage at which a stream of frames becomes a structured sporting event.&lt;/p&gt;

&lt;h2&gt;
  
  
  8. Validation on Real Video Footage
&lt;/h2&gt;

&lt;p&gt;Strong performance on individual images does not necessarily mean that complete shots are reconstructed correctly. PerformStars has therefore been evaluated on continuous practice footage, with automated results checked manually.&lt;/p&gt;

&lt;p&gt;In one evaluation covering &lt;strong&gt;124 real shots&lt;/strong&gt;, the system detected &lt;strong&gt;93.5%&lt;/strong&gt; of them. The accuracy of the &lt;em&gt;potted/missed&lt;/em&gt; outcome classification among shots for which an outcome was reported was &lt;strong&gt;97.2%&lt;/strong&gt;. Outcome-decision coverage was &lt;strong&gt;91.4% of detected shots&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;These figures measure &lt;strong&gt;shot-event detection and outcome classification—not the localization accuracy of individual balls&lt;/strong&gt;. A dedicated detection benchmark would require separate measurements such as precision, recall, mAP, and center-coordinate error.&lt;/p&gt;

&lt;p&gt;Demonstrations: &lt;a href="https://youtu.be/7VIljEMF8Oc" rel="noopener noreferrer"&gt;Video 1&lt;/a&gt; · &lt;a href="https://youtu.be/p7dny58UJ2c" rel="noopener noreferrer"&gt;Video 2&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  9. Open Engineering Challenges
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Maintaining identity through collisions.&lt;/strong&gt; This is especially difficult when visually similar balls cross paths or disappear briefly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Robustness across recording conditions.&lt;/strong&gt; Camera angle, lighting, resolution, and partial occlusion of the table increase uncertainty.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Combining neural and physical models.&lt;/strong&gt; Recognizing objects is not enough; their inferred motion should also be physically plausible.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Computational efficiency.&lt;/strong&gt; Processing large video collections needs to remain economical, including when multiple practice sessions or matches are analyzed in parallel.&lt;/p&gt;

&lt;h2&gt;
  
  
  10. Conclusion
&lt;/h2&gt;

&lt;p&gt;Our work on PerformStars illustrates why automated billiards analysis cannot be reduced to a single neural network. Ball detection is only the first layer.&lt;/p&gt;

&lt;p&gt;Reliable sports analytics requires combining computer vision, geometry, object tracking, identity recognition, physics-based modeling, and temporal event analysis.&lt;/p&gt;

&lt;p&gt;A billiards table is a compact but challenging example of a broader problem: &lt;strong&gt;reconstructing the dynamics of multiple interacting objects from incomplete visual observations&lt;/strong&gt;. Similar challenges arise in robotics and industrial machine vision.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Our goal is not merely to teach a computer to see a billiards table, but to describe the game unfolding on it in mathematical terms.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;PerformStars Research &amp;amp; Engineering · &lt;a href="https://performstars.com/research/computer-vision-billiards" rel="noopener noreferrer"&gt;https://performstars.com/research/computer-vision-billiards&lt;/a&gt;&lt;/em&gt;&lt;/p&gt;

</description>
      <category>computervision</category>
      <category>ai</category>
      <category>objectdetection</category>
      <category>machinelearning</category>
    </item>
  </channel>
</rss>
