Book Image

Python Game Programming By Example

Book Image

Python Game Programming By Example

Overview of this book

Table of Contents (14 chapters)
Python Game Programming By Example
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

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...