Raspberry Pi-Powered Sugar Launcher Uses OpenCV to Find Your Cup — and Bombard It with Sugar Cubes
The anonymous engineer behind the Equals Engineering YouTube channel has shown off an unusual sugar-cube dispenser — which uses OpenCV to target your coffee cup and automatically fling sweetness in the right direction.
"I made an auto-aiming sugar-launching robot that detects coffee cups and shoots sugar cubes into them," the host of Equals Engineering explains. "The recommendation is to launch the sugar before you put the coffee in!"
The heart of the system is a Raspberry Pi 4 Model B single-board computer, equipped with a camera linked to the OpenCV computer vision library. It's this which is given the job of detecting coffee cups — or rather, to simplify matters, a single specific coffee cup: The biggest red object in its field of vision.
"To get the cup in the middle of the frame it uses two wheels to wiggle itself back and forth," the robot's creator explains. "To measure how far to launch the sugar cubes it uses an ultrasound sensor."
Launching the cubes reliably, however, took a little doing: The mechanism is controlled via two servos, one of which controls a hook and the other a compressed spring — the release of which propels a cube on its path to the cup.
"There are quite a few parts on this little thing and something is bound to break eventually," the maker admits, "so I made a test sequence, to make sure all parts are working independently, that i can run when something goes wrong. It tests all the motors, the ultrasound sensor, and the camera in sequence."
A full video detailing the build, including plenty of target practice, is now available on the Equals Engineering YouTube channel.