Knudn
Posts: 4
Joined: Fri Jan 09, 2015 3:07 pm

Pool table project

Fri Jan 09, 2015 3:39 pm

Okay, i've never done a project on raspberry pi before so i don't really know what it is capable of, so i figured i would ask here if the project i had in mind even would be possible.

We have a 7 feet pool table and i would like to have some sort of automated score tracing. The idea i had in mind was to simply stick the pi underneath the table and just stretch cables to the 6 holes and add a switch to make the pi recognise if a ball where to fall down. I figured that would be easy enough, but the problems is to make the pi recognize what ball has fallen down, because if the pi won't recognize what ball has fallen down it cant really keep the score either. So is there a way to make this work? by a barcode? or maybe it's possible to make it recognize the number on the ball? or im i just way over my head?

Would appreciate any help :)

PiGraham
Posts: 5066
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Pool table project

Fri Jan 09, 2015 4:01 pm

Does this table have a ball chute? If all balls run past one point there are more sensing options since all snesing can be done in one place for all balls.

Some tables have something like this inside:
Image

Many home tables just have 6 separate pockets and would need 6 sensors, one for each pocket.

Colour sensors or camera might work.
You could modify the balls to insert a small RFID capsule and read the ball ID that way.

Knudn
Posts: 4
Joined: Fri Jan 09, 2015 3:07 pm

Re: Pool table project

Fri Jan 09, 2015 4:14 pm

This pool table gose down in to sepreate lines, so i would need 2 sensors. But it would need to recognize the ball pretty fast since it only roles by. And half of the balls are just striped with a color, so would the sensor be able to regenize the ball precise?

PiGraham
Posts: 5066
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Pool table project

Fri Jan 09, 2015 4:30 pm

Knudn wrote:This pool table gose down in to sepreate lines, so i would need 2 sensors. But it would need to recognize the ball pretty fast since it only roles by. And half of the balls are just striped with a color, so would the sensor be able to regenize the ball precise?
I think the simplest scheme is the RFID.

It is probably possible to measure the average colour over a large part of the ball surface, or in multiple spots around the ball, or by holding and rotating the ball. All these will take some careful working out and may be complex to design.

Maybe some of these well placed, and some clever software, could work it out.
http://www.ebay.co.uk/itm/TCS230-TCS320 ... 4630473950

User avatar
Burngate
Posts: 6532
Joined: Thu Sep 29, 2011 4:34 pm
Location: Berkshire UK Tralfamadore

Re: Pool table project

Fri Jan 09, 2015 5:55 pm

I don't play pool, but I gather the balls are different colours, some with stripes, some with numbers. When one goes down a pocket, you want to identify which one.

But surely, under the table, it's dark - no light, so they're all black. Even with a light, detecting a stripe could be uncertain if it happens to be oriented in the wrong direction.
I wouldn't expect attaching an RFID tag to a ball to do wonders for it's rolling, even if it's buried inside.

Would it be possible to have a camera looking at the table top, and see what's left? You should have plenty of time between shots.

PiGraham
Posts: 5066
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Pool table project

Fri Jan 09, 2015 6:15 pm

Burngate wrote:I don't play pool, but I gather the balls are different colours, some with stripes, some with numbers. When one goes down a pocket, you want to identify which one.

But surely, under the table, it's dark - no light, so they're all black. Even with a light, detecting a stripe could be uncertain if it happens to be oriented in the wrong direction.
LED's could light the balls. Those colour sensors use RGB LEDs and a single photosensor. Ideal for use in dark places.
Of course the roll and the stripe and number rule out a single sensor (excluding some fancy manipulation of the ball.)
I think several sensors could sample enough points to get a signature, but one ball will have many signatures, depending on it's orientation on the track, hence the 'fancy software' requirement.
Burngate wrote:I wouldn't expect attaching an RFID tag to a ball to do wonders for it's rolling, even if it's buried inside.
That is certainly an issue, but it may not be out of the question. Those capsule tags they use for pets are very small and it might be feasible to maintain balance.
Burngate wrote:Would it be possible to have a camera looking at the table top, and see what's left? You should have plenty of time between shots.
Yes, that is definitely possible. There are pool playing robots that use that technique. If there is some open source code to do that reliably that would be worth investigating. Implementing the ball ID yourself could be tricky.

Putting the camera inside to view balls on the track is also viable, and since the balls are rolling you get multiple views that will show the stripes etc. Not an easy vision task though.

Maybe there are some good hits in here

PiGraham
Posts: 5066
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Pool table project

Fri Jan 09, 2015 6:21 pm

There is a simple solution that suits some pool games. For 8-ball use a two-colour ball set. If you use red/yellow/black balls simple colour sensors can ID which player's ball (or black, or cue) has been pocketted.

There are other complications.

Sinking order. Depending on your preferred rules, it may be a foul to pot an opponents ball before your ball, but it may be legal if the opponent's ball drops after yours.

In most 8-Ball rules it is a foul if you don't hit your own ball first, even if you pot one of your own balls as a result. Checking balls in the pockets / on the track can't score that.

It's a foul to fail to hit a ball with the cue ball.

To cover all rules you would have to track the balls on the table in real-time. I think that is beyond the capabilities of the Pi.

PiGraham
Posts: 5066
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Pool table project

Sat Jan 10, 2015 12:08 pm

Check the rules!

Straight Pool
4.7 Scoring
The shooter scores one point for legally pocketing a called shot. Each additional ball pocketed on such a shot also counts one point. Fouls are penalized by subtracting points from the offending player’s score. Scores may be negative due to penalties from fouls.


4.9 Standard Fouls
If the shooter commits a standard foul, a point is subtracted from his score, balls are spotted as necessary, and play passes to his opponent. The cue ball remains in position except as noted below.

The following are standard fouls at 14.1:

6.1 Cue Ball Scratch or off the Table The cue ball is in hand behind the head string (see 1.5 Cue Ball in Hand).
6.3 No Rail after Contact
6.4 No Foot on Floor
6.5 Ball Driven off the Table (All object balls driven off the table are respotted.)
6.6 Touched Ball
6.7 Double Hit / Frozen Balls
6.8 Push Shot
6.9 Balls Still Moving
6.10 Bad Cue Ball Placement
6.11 Bad Play from Behind the Head String For a foul under the second paragraph of 6.11, the cue ball is in hand behind the head string for the incoming player.
6.12 Cue Stick on the Table
6.13 Playing out of Turn
6.15 Slow Play
One point per ball means we don't need to ID the balls if we manually apply penalties.
Leave the complex and variable foul rules to the players/referee to decide and use a foul button to apply penalty points.

Now we only need simple ball detectors. A through-beam opto sensor per track or per pocket will do. Locate it a little off-centre so that even two touching balls will trigger it twice.

I have seen a version of 9-ball that scored the number of the ball. That would be more difficult.

Knudn
Posts: 4
Joined: Fri Jan 09, 2015 3:07 pm

Re: Pool table project

Mon Jan 12, 2015 9:09 am

Thanks for the help, but i've been thinking of a design. Would it work to make the ball stop in the bottom of the rail and put 3 or 4 of these http://www.ebay.co.uk/itm/TCS230-TCS320 ... 4630473950 around the ball? Than if 3 of the sensors gets a white color and one gets yellow, it's pretty safe to assume that the ball is a yellow striped ball. And if the PI recognize that it has returned the color, it releases the ball.

Woud this work?

Knudn
Posts: 4
Joined: Fri Jan 09, 2015 3:07 pm

Re: Pool table project

Mon Jan 12, 2015 10:25 pm

Anyone?

PiGraham
Posts: 5066
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville

Re: Pool table project

Tue Jan 13, 2015 10:53 am

Knudn wrote:Thanks for the help, but i've been thinking of a design. Would it work to make the ball stop in the bottom of the rail and put 3 or 4 of these http://www.ebay.co.uk/itm/TCS230-TCS320 ... 4630473950 around the ball? Than if 3 of the sensors gets a white color and one gets yellow, it's pretty safe to assume that the ball is a yellow striped ball. And if the PI recognize that it has returned the color, it releases the ball.

Woud this work?
Possibly. All standard balls have some white and black on them, so you may need more that 4 sample points. You need to think about that. Get a ball and set up some pointers to represent sensors. Try to orient the ball so that the wrong detection occurs.

If you let the ball roll then each sensor sees more samples of the ball, so that may help.

Return to “Beginners”