How does it work?
Dice Detection
The first part of the Catanomous system is the dice detection. It uses a Raspberry Pi + Camera module to detect what number was rolled on the dice. It communicates the detected roll to the main system via Bluetooth. An image of the dice box and corresponding computer vision output is shown above. To detect the roll, we isolate the red parts of the image and use a Hough circle transform to count the number of dots.
Mechanical Card Dealing
We use an array of continuous servo motors mounted with rubber wheels to push the cards out of our custom card holders. The card dealers are mounted on a rotating platform that is also driven by a continuous servo. All of these motors are driven by our custom PCB, which uses an Atmega 328P as its microcontroller. The enitre card dealing system is controlled via SPI by the main Raspi processing unit mounted above. The card dealer and PCB are shown in the images above.
Board Detection
To detect pieces, tiles, and numbers on the board, we use OpenCV for computer vision and Tesseract for optical character recognition.
- The first step of our CV pipeline is to use Canny edge detection to highlight the edges of the hexagons. We then use the Watershed algorithm to segment the image into separate contours. The output of the Canny filter and initial markers that we use for the Watershed algorithm are shown below:
- We then replace each hexagon with its average color over the area of the hexagon and use a k-means algorithm to cluster similar colors together. We identify and label each group as one of the 5 resources, based on its HSV color values. The original resources and corresponding k-means output are shown below:
- We isolate the numbers on the board by looking for the circular tile within each hexagon. We use Tesseract, an open source OCR library, to identify each number.
- We augment the settlement and city pieces with circular markers to make them easier to identify. It was initially very difficult to differentiate cities vs settlements so we use white circles under settlements and black circles under cities. For our CV algorithm, we use a Hough circle transform to identify all possible locations of these pieces and then use color identification to determine whether a player's piece is within that circle. The result of the Hough circle transform and resulting identified pieces are shown below (the green outline indicates a settlement and a red outline indicates a city):