To detect pawns we decided to use android camera (with IP Webcam app - it's very good by the way). Phone was mounted over the board to have clear view of situation on it. As light source we have used built-in LED.
The board with mounted camera:
Rukia designed the algorithm and Gregg implemented it:
- crop and transform image to square board of constant size (600x600 px),
- splits it into separate fields,
- for every field:
a) applies median blur,
b) applies Gaussian blur,
c) applies Canny edge-detector,
d) search for circle using Hough method,
e) if the circle was detected it threshold the image and then recognize color of the pawn (it depends of white pixels in
Then build an array of field to pass it forward to game logic.
Board after transformation with marked detected pawns:
And the same board after edge detector:
Whole algorithm written in python is on GitHub