How to track cue ball movement?

straightline

AzB Silver Member
Silver Member
It’s hard as hell to learn the patterns from the pros because I can’t tell what the layout is and try to predict it before they shoot. Some ball sets are worse than others. The cylclop was the worst by far, no other set was even near as bad. Centennials and aramith tournaments are near the top. Super aramith pros are in the middle. And surprisingly, the MR Emily set is decent to distinguish. It’s not every ball and every color, but enough to have issues.

In person when I’m playing it’s much easier to distinguish the colors, plus I can see the numbers. I have fouled a handful of times over the years while gambling, shooting at the wrong ball though.
Have you thought about ball designs that would aid players with perceptual issues?
 

bb9ball

Registered
Cue ball tracking, much less cue ball identification, is very difficult to do from a single source video due to shadows and noise artifacts.

Here is an attempt I made using OpenCV to automatically identify the shot line of the player, and the distance between the CB and OB. It is unreliable and depends heavily on the camera being used.

It can be done but with an expensive multi camera set up and calibrated software.



I just ran across this. I don't know how they are determining the shot line.
 

pw98

Registered
Cue ball tracking, much less cue ball identification, is very difficult to do from a single source video due to shadows and noise artifacts.

Here is an attempt I made using OpenCV to automatically identify the shot line of the player, and the distance between the CB and OB. It is unreliable and depends heavily on the camera being used.

It can be done but with an expensive multi camera set up and calibrated software.

Lens distortion is definitely a problem as you have identified. It will definitely have an effect on solution I am about to suggest if the camera is fish-eye. Of course there are software solutions to fix fish-eye, however.

So basically I think that it can be done with a single camera using inverted 3d projection matrices. There is good information here: https://stackoverflow.com/questions/76134/how-do-i-reverse-project-2d-points-into-3d

I also think ball detection can be done as well, however, openCV is only part of the solution. Once a ball is detected via OpenCV it needs to be re-constructed. To do this it requires fitting a circle around the ball using r^2=x^2+y^2 formula. An alternative method would fitting x=r*sin(theta) and y = r*cos(theta) circle formula.

A (I think simpler and more precise) method of doing it would be something related to an inverted version of Bresnham circle drawing algorithm (https://en.wikipedia.org/wiki/Midpoint_circle_algorithm).

Basically the nice thing about the balls is since they are round they theoretically project into a perfect circle in 3d->2d.

To put it simply the bresnham line/circle drawing algorithms exploit the fact that there are only so many pixel patterns possible when drawing a circle on a cartesian coordinated 2d display. So to draw lines and circles faster in software these finite patterns are repeated instead of invoking the algorithms y=mx+b or r^2=x^2+y^2 which are slow when done in floating point, and even when algorithms are converted into integer versions these finite identities speed it up more.

So to put it simply using bresnham concept if you can detect a tiny bit of the perimeter of the ball you should be able to:
1. Calculate the radius and center point.
2. Re-construct the rest of the ball accurately.

So finding the balls using a reverse circle drawing algorithm should work well by running it against the areas openCV already correctly detects as balls.

Once you find the center of the balls you can project lines from inverse camera matrix into them 1.25" to find their center in the 3d space. Once you have the 3d coordinates of the balls you can rotate them into 2d space and do whatever you want with them and draw lines, etc, then project them back into 2d space (ie draw them on the table).

Please forgive how badly this is written as im tired.
 
Last edited:

straightline

AzB Silver Member
Silver Member
I just ran across this. I don't know how they are determining the shot line.
Probably projected image. Balls have to be placed accordingly.
 
Top