Inspiration

That crummy D20 always rolls low! Another 1... Dice all have natural, uncontrolled variations, and aren't likely to have a perfect distribution of results. But rather than leaving our luck up to chance, we wanted to find out just how well our dice roll: statistically! While an ideal die would land on each face the exact same number of times over a sufficiently large number of samples, real die will land on some faces more than others. This may or may not result in an average roll that differs from the ideal case, and by computing this, we can find dice that legitimately roll better or worse than others (lucky and unlucky dice, if you will).

What it does

Diceview consists of a hardware component which automatically rolls a number of dice and then captures an image of the bottoms of those dice. A machine vision component extracts the numbers displayed on each die, and feeds them into a GUI. The GUI component tracks how many times the dice landed on each faces, and presents this data through a number of graphs. It also computes the average roll value of each die for an at-a-glance metric of die performance.

How we built it

The Diceview apparatus is mostly custom, consisting of 3D-printed parts as well as laser-cut acrylic (all modeled in Fusion 360), plus some COTS fasteners. The electronics package is an NVidia Jetson development kit with a camera module. Running on the Jetson is a Python application, which uses OpenCV for image processing and Tk plus Matplotlib for the user interface.

Challenges we ran into

The servo we used to rotate our dice chamber moves 180 degrees, mechanically, which is as many degrees as we hoped to rotate the chamber. As it turned out, it can only be commanded to move 130 degrees. This meant we had to remove some baffles we put in the chamber, perhaps at the cost of randomness.

Matplotlib did NOT want to play nice with Tk's grid geometry manager. It virtually refused to adopt the size of its container, with the ultimate resolution being to spoof a resize event with the (unchanged) dimensions, instead of making a draw call at all.

Accomplishments that we're proud of

Waking up at 7am on a Saturday

Figuring out that you have to call pack_propagate(False) to stop resizes from propagating to a GRID layout.

Writing a thoroughly reusable threaded GUI for OpenCV pipelines.

What we learned

Machines are Cool

What's next for Diceview

We're going to roll a massive amount of dice... and then save all the good ones for ourselves!

Built With

Share this project:
×

Updates