Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Python Game Programming By Example

You're reading from   Python Game Programming By Example A pragmatic guide for developing your own games with Python

Arrow left icon
Product type Paperback
Published in Sep 2015
Publisher
ISBN-13 9781785281532
Length 230 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Toc

Building the analyzer


The CheckersModel module is the eyes and the brain of our project. It brings together everything except the GUI. Specifically, it depends on NumPy, OpenCV, scikit-learn, and our ColorUtils and ResizeUtils modules, as reflected in the following import statements:

import numpy
import sklearn.cluster
from CVBackwardCompat import cv2

import ColorUtils
import ResizeUtils

Note

Although we are combining image capturing and analysis into one module, they are arguably distinct responsibilities. For this project, they share a dependency on OpenCV. However, in a future project, you might capture images from a camera that requires another library, or from an entirely different type of source, such as a network. You might even support a wide variety of capturing techniques in one project. Whenever you feel that image capture is a complex problem in its own right, consider dedicating at least one separate module to it.

To make our code more readable, we will define several constants...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime