Best ML Model for Real-Time Egg Counting on Raspberry Pi
hello everyone!
I’m working on a real-time egg-counting project using a Raspberry Pi and computer vision. Originally, I thought I could use OpenCV with contour detection for a quick, lightweight solution. The plan was to convert images to grayscale, reduce noise with blurring, and use edge detection to find contours representing eggs. But as I tested it, contour detection turned out to have several big limitations that made it unreliable for this project.
One of the main issues was "lighting sensitivity" even small changes in light, shadows, or reflections would throw off the detection completely, often causing the egg count to vary wildly. Another major problem was "overlapping eggs"—if eggs were close together, contour detection often couldn’t separate them and would count multiple eggs as one. Lastly, "background interference" was a big challenge. The algorithm would sometimes pick up background textures or objects as “eggs,” adding false positives to the count.
Because of these issues, I decided to switch to training a model , which should handle these challenges better. Which specific ML model would you recommend for detecting and counting in real-time on a Raspberry Pi? I need something that can handle varying lighting conditions and overlapping objects while still being lightweight enough to run smoothly on the Pi.
27 Replies
Which Pi?
Can I ask, how does training a custom model fix this issues you found?
Raspberry pi 3
Because it can actually learn from examples rather than r fixed rules like contour detection does. training a model with lots of different images of eggs, it starts to recognize them in all sorts of conditions , different lighting, overlapping positions, and even with tricky backgrounds. . The model picks up on subtle patterns and features that make an egg an egg, and that why it may be a better solution for my project because it Real time detection
Why did you choose a Pi 3?
Am doing a real time recognition and counting, it have a good processing power to handle computer vision task in real time
Seen this? https://www.raspberrypi.com/products/ai-kit/
Raspberry Pi
Buy a Raspberry Pi AI Kit – Raspberry Pi
A kit containing a Hailo AI module pre-installed on the M.2 HAT+
yeah I would focus on this first, why don't you work on training a couple of models then we can observe from that?
Yeah,i was thinking about using Yolov5 for the training first, i will try it and share the results
Can i ask , is it worth to invest in the AI kit since i have Pi 3 already.
Are you doing this for fun? For research? Trying to commercialize? What’s your end goal?
No, hoping i can sell it to a production company
I personally find a lot of companies in denial to associate with rpi at an industrial level. Had one client cancel the agreement as i showed the demo in a rpi
What do you suggest i work with !
Was waiting to see what you said @melta101 but was going to ask @wafa_ath if the hope was to migrate to a pi compute module at some point or something else?
Guessing he will say beagle-ai…
Have you discussed this with the company?
what are the expecttions or so?
was going to suggest coral TPU
Have you worked with the Y-AI yet?
no but actually
I have used it for classification based problem statement and it had a good support for a lot of things
not yet
I was planning to get one in a few month
I need to a few others devices to test drivers for K3 series
@wafa_ath
i had access to a laptop with a free mini PCle port
so i had used this https://coral.ai/products/pcie-accelerator
Coral
Mini PCIe Accelerator | Coral
Integrate the Edge TPU into legacy and new systems using a Mini PCIe interface.
but in all honestly,
I would suggest to have a talk with the company and understand what is more important for them.
Some company just wants it to work(like my current company)
No need to waste unnecessary money if the result is the same
Not yet I want to build a working prototype first so I can show it around to companies and let them see it in action.