If you're ever short a pair of dice and an online alternative won't do, you need no longer despair. Maker firm Intridea has created a real-world, internet-connected dice roller that can be operated via Twitter. DiceBot will roll the dice when prompted and then respond with a picture of your score.
DiceBot is, of course, an experiment and proof-of-concept rather than a practical solution. It forms part of Intridea's exploration of the Internet of Things, "social machines" and "human-software-hardware interaction." Such experiments, the company says, are helping it to develop a better understanding of our relationship with the increasing number of "specialized hardware devices" available to us, such as the Nest thermostat and the Fitbit Flex. DiceBot is the first of these exploratory projects that Intridea is running, company co-founder Dave Naffis tells Gizmag.
"This project in particular seemed like a lot of fun because it gave us the opportunity to take something old, a vintage dice rolling machine, and give it a new life on the internet that we could share with others," he says. "It also gave us the opportunity to tie together a number of different technologies we're quite interested in, including Rasperry Pis, Twitter API, a camera and computer vision (using OpenCV), and a real-time Single Page App (SPA) using AngularJS."
At its core, DiceBot is a 1920s antique dice game with some additional hardware and software. The game casing that contains the dice is mounted within a wooden frame, with a camera mounted at the top, looking down. The game casing is modified with a motor, which is controlled by a Raspberry Pi and used to spin the dice.
The Raspberry Pi is connected to the internet and a Ruby script listens for tweets directed at @IntrideaDiceBot that contain the hashtag #rollthedice. When a relevant tweet is detected, a job is placed in the system's queue.
A second Ruby script looks for jobs in the queue. When one is found, a Python script pulses the motor for half a second via some GPIO pins connected to an L298N bridge motor driver control. The dice roller is activated briefly and rattles the dice. At the same time, a tweet is automatically sent back to the user informing them that their roll is underway.
When the dice have been rolled, the camera takes a photo of the result using RaspiStill. An OpenCV image recognition program is employed to count the dots facing up on the dice. The photograph is watermarked with the user's dice score and is automatically uploaded to the DiceBot microsite.
Finally, another automatic tweet is sent to the user containing their score (so they never actually have to leave Twitter), together with a link to the website for a look at the photo.
Among the difficulties faced in producing DiceBot were camera angle and lighting. The camera was initially mounted to the side of the dice roller and, as result, the dice dots were not being picked up properly. This was resolved by moving the camera to an overhead position. The lighting issue, however, is persistent. Any fluctuation means that the system will count too few or too many dots.
"The lighting has to be strong enough to reduce shadows but at the right angle or indirect to reduce reflections," explains Naffis. "I have a couple of photography lights setup around the device at proper distances to get decent results. The detection is probably 95 percent accurate. There are still a few misreads now and then."
DiceBot was created, for the most part, over the course of a weekend, having initially been built as separate parts. The total cost was about US$130, which included the Raspberry Pi ($40), a Raspberry Pi camera ($30), a Wi-Fi dongle ($8) and a dice roller purchased on eBay ($9).
The video below shows DiceBot in action.
See the stories that matter in your inbox every morning