Edge Impulse logo
Blog Post

An Egg-cellent and Egg-citing Eggs-periment in Edge ML

Computer Vision, TinyML, Machine LearningThis computer vision system monitors a bird's egg production using a FOMO-based model on the OpenMV Cam H7.

Nick Bild

September 19, 2022

    The egg industry may not make headlines in the national news very often, but that does not mean it is not serving an important role in our lives. Poultry eggs are one of the healthiest foods available, despite also being one of the least expensive at about fifteen cents per egg on average. And the vitamins and high-quality protein found in eggs do not go to waste — every American eats an average of 263 eggs each year according to the American Egg Board. As of June of 2014, the US was producing nearly 8 billion eggs annually to try and keep up with this demand.

    Needless to say, that is a lot of eggs, and keeping up with that demand presents producers with a lot of challenges. Research has shown that feeding hens on a strict schedule improves both the quantity and quality of eggs that they produce by controlling their weight and reducing stress about future food scarcity. To ensure that the feeding schedule and quantity is optimal, and that the number of eggs produced is as expected, food availability and egg counts need to be tracked. For large producers that may have hundreds of thousands of birds, implementing methods to track these metrics can be overly burdensome and prohibitively expensive. It can also be a problem for smaller producers that do not have the resources to implement a commercial solution.

    The setup on top of the cage

    Engineer Kutluhan Aktar has built a device that may be eggs-actly what poultry egg producers need to better manage their operations. Using inexpensive hardware and the Edge Impulse machine learning platform, he has designed a tool that can monitor the availability of food and the number of eggs laid in a bird’s enclosure. For each device, the results can regularly be reported to a central server where producers can spot efficiency issues and act swiftly to optimize production, or detect the beginning of a potential outbreak of disease among the flock so that it can be dealt with before it spreads.

    Fitting the hardware components into the case

    To keep things as simple and inexpensive as possible, an OpenMV Cam H7 was chosen as the primary hardware platform. The OpenMV Cam H7 is tiny, inexpensive, and it comes standard with a 480 MHz Arm Cortex-M7 processor and 1 MB of SRAM to run machine learning algorithms at the edge. The onboard 640x480 resolution 16-bit color image sensor works perfectly for capturing images of the device’s surroundings, such as the inside of a chicken coop. For Wi-Fi connectivity, a WizFi360-EVB-Pico development board was wired to the OpenMV Cam H7. The powerful DFRobot LattePanda 3 Delta 864 single-board computer was set up as a web server to host an application that aggregates data from the egg counter devices. As a finishing touch, Aktar 3D printed a bird-themed case for the device to make it sturdy and compact for real-world use.

    Labeling the training data

    Based on past experiences using Edge Impulse, Aktar knew that the FOMO object detection algorithm would be ideal for this use case. FOMO is optimized for running on resource-constrained devices like the OpenMV Cam H7, but it does not compromise on accuracy. But before the FOMO algorithm could recognize an egg or the amount of food remaining in a feeder, it would need to be trained with the help of some example images. Aktar happens to raise quails as pets on his balcony, so he set the assembled device on top of the quail cage and started capturing images.

    After collecting the training dataset, it was uploaded to Edge Impulse. The AI-assisted labeling queue was then used to draw bounding boxes around the objects to be detected (i.e.: eggs, feeder). This information gives the algorithm the fuel it needs to learn to count eggs and distinguish between a full and empty feeder, so Aktar moved on and designed an impulse to process the data.

    The impulse starts with an image preprocessing step that extracts the most meaningful features, which serves to improve the accuracy of the model while also reducing the required computational resources. The features are then processed by a FOMO object detection model. A few of the model’s hyperparameters were tweaked to be optimal for the task at hand, then the training process was kicked off.

    After training completed, the model was validated against a test dataset that had not been included in the training process. This validation showed that the model achieved an accuracy rate of 100%. This result is eggs-cellent, but maybe a little bit too good. Aktar suspects this result was achieved because he collected a very small training dataset with little variation.  In the future, he intends to collect a larger dataset to ensure that the model will be robust under varying conditions.

    The completed impulse design

    In any case, the model was working very well for Aktar’s quail cage, so he was ready to deploy the machine learning pipeline to the OpenMV Cam H7. Because this board is fully supported by Edge Impulse, he could simply download a firmware image using the deployment tools and flash it to the board. Since Edge Impulse supports a wide array of hardware platforms, it would be trivial to deploy this same pipeline on alternate devices.

    After installing the completed device on top of the quail cage, it began regularly monitoring the egg count and feeder status. That data was sent to a web API and stored in a database on the DFRobot LattePanda 3 Delta 864 computer, and text messages were sent to Aktar via Twilio.  ith some off-the-shelf hardware platforms and the simple-to-use Edge Impulse platform, Aktar showed just how easy it can be to bring your machine learning-powered ideas to life.

    SMS alerts sent by the egg counter

    The build was extensively documented by Aktar, so do not miss reading up on this one. And after you do, you can clone his public Edge Impulse project as a starting point in building your own creation.

    Want to see Edge Impulse in action? Schedule a demo today. 


    Are you interested in bringing machine learning intelligence to your devices? We're happy to help.

    Subscribe to our newsletter