1 of 21

Billiards Scoring Using CV

Team 7: Andrew Winke

Coleman Dimmer

Cameron Lettieri

Zachariah Morris

Quang Le

2 of 21

Overview about the project

  • Application to keep track of the scores

when playing pool

  • Application using Computer Vision
  • Ordered by Brandon Carlson

3 of 21

Questions We Had For The Client

  • Where do we use the application?
  • Preferences in regards to how the application is made?
  • Significant functions in the application?

​

4 of 21

What We Decided To Do

  • We decided to use Android Studio to build our application
    • We chose this because it was an app our group was familiar with
    • Also would make it easier to use a phone’s camera to get video of the billiards table
  • We did our initial research of OpenCV in Python, but eventually plan to integrate it in Android Studio
    • We require us to translate to code into Java
  • Eventually, when the main component of the project is complete, we may decide to add a server element to the app
    • Would store game history, implement social elements, and add a lobby system

5 of 21

Anticipated Challenges

  • Integrating OpenCV in Android Studio
  • Differentiating between different balls on the table
  • Remembering different objects when the camera is obstructed

​

Will go more in depth on these later in the demo!

6 of 21

Benefits

  • Project was proposed by client as mostly researched focused
    • We will have intellectual property rights to the app
    • We can continue on the app after we are done with the semester
  • Allows us to work with OpenCV and work with interesting new tools that we were not previously familiar with
  • It will be a lot of fun!

​

​

7 of 21

What is Android Studio?

  • integrated development environment (IDE) by Jetbrains
  • Focus on Android application development

8 of 21

Why Android Studio?

  • End Goal - working mobile app (Specifically Android)
  • All members are familiar with it
  • Gives tools need for simple development (screens, transitions, etc.)

9 of 21

Android Studio Challenges

  • Troubles with implementing 3rd-party libraries (OpenCV)
  • Development mostly in python so far
    • Keep in python - use add-ons like Chaquopy to run Python on Android Studio?
    • Transfer to Java - rewrite everything from Python to Java

10 of 21

Artificial Intelligence

  • Artificial Intelligence is like giving computers the ability to think and make decisions like humans
  • Chess
  • It's like having a buddy who knows all the rules and keeps track of the game for you

11 of 21

Machine Learning

  • Machine Learning helps computers learn from information or data, just like how we learn from our experiences
  • Netflix Recommendations
  • The more games it "watches," the better it gets at keeping score

12 of 21

Computer Vision

  • Computer Vision is like teaching computers to use their "eyes" (cameras) to understand pictures and videos
  • Self driving cars
  • Using the camera to look at the billiard table, and then it can recognize the balls and where they are on the table

13 of 21

OpenCV

  • "Open Source Computer Vision Library"
  • Breaks down images to simple objects
  • Watches the game
  • Ensures accurate scoring

14 of 21

Demo!

15 of 21

Code: Main Logic

  • Allow user to run table setup as many times as needed to recognize the table.

​

​

  • Enter the main while-loop and track the balls on the table.

16 of 21

Code: Table Setup

  • User pauses video and clicks each of the 6 pockets in order.

​

  • Once all pockets are selected, table is outlined and loop exits.

​

17 of 21

Code: Warping the Frame

  • Using the table bounds, generate transformation matrix.

​

  • Extract pixels for table and transform to fit 2:1 aspect ratio.

18 of 21

Code: Contour Boxes

  • Use color thresholds to generate a mask. Smooth the mask with convolution.

​

  • Outline mask with white to improve detection around edges. Extract the contours.

​

  • Draw boxes around the contours on the table.

​

​

19 of 21

Code: Main Loop

  • Read frame.

​

  • Transform.

​

  • Draw contours.

​

  • Show the image.

20 of 21

Code: Future Plans

  • Store locations of distinct balls and recognize when a ball has moved.

​

  • Recognize when a ball goes into one of the pockets.

​

  • Recognize when one player’s turn has ended and keep each player’s score.

21 of 21

Questions?