A never-ending supply of cold beer at KI labs to maintain employee happiness.
“Here’s to ̶a̶l̶c̶o̶h̶o̶l̶ BeerBot: the cause of, and solution to, all ̶o̶f̶ ̶l̶i̶f̶e̶’̶s̶ office problems.”
Beer + Bot = Success
The humble origins of BeerBot are linked to the first internal KI labs hackathon. It was held earlier this year with the goal of pushing our engineering skills and creativity to the limit within the span of approximately 36 hours.
[Spoiler] We didn’t win the hackathon but managed to snag a bronze 🥉
Our “dream” team consisted of Daniel Cachapa, Markus Fuchs and Josh Friedman (me). The original idea involved sticking a camera in the fridge, specifically the beer fridge, and building a slackbot. Combine the two and 💥 — out comes a BeerBot.
BeerBot monitors the beer fridge with simple image processing to identify the number and coldness of all bottles. It is continually tracking to ensure realtime beer updates. Lastly, the all important feature is its capability to proactively alert when the beer supply is critically low.
In short, it is a modern, reliable, scalable solution to an everyday problem — “do we have beer? is it cold? will we run out? should we reorder?”.
We designed BeerBot to be (somewhat) non-intrusive and require minimal maintenance. The following hardware was required to get it up and running.
- Raspberry Pi 3B+
- (fish eye) infrared camera with infrared illumination
- duct tape, duct tape, duct tape
- beer, beer, beer
The infrared camera was mounted on the inside of the fridge in several iterations. Brightness with the infrared illumination was an immediate issue upon taking BeerBot’s inaugural photo. We implemented several “designs” to ensure best lighting with any available materials — napkins, paper, etc…
The underlying BeerBot engine™ (not actually trademarked) consists of the following processing pipeline.
BeerBot internals are summarized based on its four main “components”.
The first step in triggering BeerBot is to identify when the fridge door has been opened. The infrared camera is triggered every 5 seconds to take a low resolution image of the fridge, forming a sort of template. The state of the fridge is determined by comparing the template against the latest image. Too great of a difference (thanks to ImageMagick) indicates a change of state.
The correct change of state (i.e. closed to open) triggers the capture of a high resolution image of the inside of the fridge. This forms the basis for all image processing. In short, a binary image is created with a dynamic threshold (OTSU) where likely bottle “blobs” are identified.
The Bottle Detection yields the centroids of each bottle with an attached timestamp (i.e. when the image was captured). Tracking bottles involves matching their position in time based on deviations of each centroid. The age is calculated by bottle based on a successful match.
Finally, the bot contains all logic for handling user requests. There is both an listener and alert process. The listener handles all requests through slack regarding the current state (
/inventory) and “coldness” (
/photo). The alert is responsible for bugging all users regarding the dangerously low beer supply (based on the output from the Bottle Detection).
What’s next for BeerBot?
BeerBot is definitely not production-ready (and likely never will be) but the following areas can be improved.
- camera calibration (fix brightness and distorted field of view)
- smarter image processing (train an image classification model)
- distinguish between different bottles
- automatic beer purchasing (trigger online purchase based on inventory)
Please get in contact if you’re interested in BeerBot and/or contributing to its continued success. BeerBot is always open for any issues or pull requests. All contributions are greatly appreciated.
We are also keen to “expand” BeerBot to any (and ideally) all fridges in Munich. Get in contact if you are excited to see BBaaS (BeerBot as a Service).
Finally, check out www.ki-labs.com for more information about our great products and services.