Count the Bees in Your Hive with a Raspberry Pi and Computer Vision

Urbanites may find it surprising, but beekeeping is a fairly popular hobby among people who have the space for it. Mat Kelcey was one such…

Cameron Coward
a year ago

Urbanites may find it surprising, but beekeeping is a fairly popular hobby among people who have the space for it. Mat Kelcey was one such person who had the space and inclination to tend to a bee hive, and now has a bustling community of bees in his backyard. But, this brought an important question to his mind: how many bees are going in and out of the hive? To answer that question, he built a custom computer vision tracker on a Raspberry Pi.

Kelcey’s tracker was going to be outside, so the entire setup was built inside of a plastic tub. In that container is a Raspberry Pi, a 2500mAh LiPo battery, an Adafruit PowerBoost 500 LiPo charger, and a Raspberry Pi camera. Outside of the tub is a small solar panel to keep the battery charging during the day. Setting that all up was fairly straightforward, but actually tracking the bees was the tricky part.

To do that, Kelcey programmed a neural network to analyze the still frames from the Raspberry Pi camera to detect the bees. However, it doesn’t just count the bees in each frame — that wouldn’t be particularly useful, as it would just count the same bees over and over again. Instead it detects the bees in the frames and then monitors their movement between frames to track individual bees over time. He was even able to gather data from day to day to generate graphs of bee movement based on the time of day — they seem to be particularly active in the late afternoon. If you have a beehive and want to try this yourself, Kelcey has made his code available over on GitHub.

computer vision
Related articles
Sponsored articles
Related articles