Project Abstract:

Billiards and its derivative games such as 8-ball and 9-ball are highly popular games in the United States, both competitively and recreationally. In a competitive league, player rating systems are used to the competition interesting regardless of skill level. All rating systems rely on tracking either the number of games won or the number of balls pocketed. Due to the pace of the games, this can sometimes be difficult. We have developed a system capable of determining the winner of a game of 9-ball by keeping track of the number of balls present on the table and whether or not the 9-Ball and cue are on the table. The system utilizes a webcam and image processing techniques such as thresholding and primary morphological
operations to determine the presence of balls on the table. The result is a system that can accurately determine when a game is over and which player has won, while being able to handle situations such as clustered balls and table obstructions.

Overall Top Code:
This is a view of the top code file.  This file has much of the intricacies of the code hidden but can provide an idea of the complexities of such a problem.  For further understanding of the code please refer to the flow chart page with explanation.

Flow Chart:

You begin at game start and collect frame data, the game then checks to see if the cue and nine are on the table.  The game then checks to see if the cue has moved from one iteration of the loop to the next.  If it has the game moves into a state that collects a new frame and checks to see if the cue has moved from the last reset.  Once the cue has stopped moving the game collects a new frame and checks to see if the number of objects have changed.  If the number of objects has changed then a player change does not occur.  The opposite happens if the number of balls didn't change.  The game then re-enters the the original check which both checks for cue and nine existence.  If the game detects that the nine does not exist it stops the game and reports which players turn it was.  The game is over and the game has a string output that reports the winner.  The game also has a case that detects when the cue does not exist, it changes the player and waits until the player hits the resume button to continue play.  The system also has a built in foul button as it will not handle contacting balls out of turn, this button checks the game into the same case as when the cue doesn't exist and waits until the player re-presses the foul button.  You may refer to the state transition diagram for pictorial detail.   

Game Simulation:

Senior Design Presentation