GithubHelp home page GithubHelp logo

radar3699 / pool-vision Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 1.0 82.3 MB

A fast and robust Computer Vision system for pool games.

License: MIT License

Python 100.00%
deep-learning machine-learning computer-vision object-detection pool-game

pool-vision's Introduction

Pool Vision

Pool Vision is a project for quickly converting top-down images of pool games to a list of ball types (solids, stripes, cue, eight) and positions. Pool Vision leverages a 2 network hybrid approach to combine the speed of classical computer vision with the accuracy of deep learning methods, all without any specialized hardware.

Motivation

This project was created because existing fast computer vision systems for analyzing pool games were highly innacurate and non-generalizable (not robust to changes in lighting, cue sticks or people in the image, etc.). Additionally accurate deep learning solutions were very slow and only practical with GPU computation.

Description

alt text

As mentioned above, Pool Vision leverages two neural networks, a lightweight 'priority' network and a heavyweight Inception-based 'classifier' network to analyze an image from a pool game. The lightweight 'priority network' scans through the image with a sliding window in traditional computer vision style. It is trained to discriminate game-relevant objects (different types of pool balls in different conditions and orientations) from non-game relevant objects (hands, arms, people, cue sticks, shadows, empty table, chalk, etc.) and can be fed-forward in about a milisecond on a CPU. At this point we have a heatmap of probability that a game-relevant object is in that area. (Note the human hand has high probability, this is a false-positive which will eventually be weeded out by the classifier network)

alt text

We then run a local-maximum algorithm on the heatmap to obtain a list of coordinates in which something game-revelant is probably there.

alt text

The small images around these coordinates are then fed to the heavyweight 'classifier' network. It is an Inception V3 very deep convoltional neural network base modified in a transfer learning process to discriminate between game objects (solid ball, striped ball, cue ball, eight ball, none-of-the-above) and takes about 1 second to feed forward on a CPU. (Note the hand is labelled 'none' because this network can weed out false-positives from the priority network)

alt text

By leveraging this dual-network approach we are able to obtain the speed of hard-coded approaches, but the accuracy and robustness of deep learning solutions, without specialized hardware.

Usage

Installing

Pool Vision uses TensorFlow and Keras for deep learning, as well as cv2 for image loading as well as numpy and matpotlib for numerical computation and visualization. All requirements can be installed by running

CPU only:

pip install requirements.txt

CPU + GPU

pip install requirements_gpu.txt

Multiple games with multiple images

With each game in a different folder in games_folder, and a sequence of game images within each game folder, run:

python classify_game_images.py 

And the output will be a txt file for each image in each game. By default they are in the same location as the images but this can be changed in the script.

Individual Networks

The function which takes an image and feeds it forward through the priority network can be found in priority.py and likewise for the classifier network can be found in classifier.py.

Built With

  • Tensorflow - The framework used for the classifier network
  • Keras - The framework used for the priority network
  • Google Inception - The base network transfer learned from for the classifier network

pool-vision's People

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.