Egg Detection

OpenMV related project discussion.
TenaciousB333
Posts: 2
Joined: Mon Nov 04, 2019 8:08 pm

Egg Detection

Postby TenaciousB333 » Wed Nov 27, 2019 7:45 pm

I am trying to use OpenMV to detect and eventually count eggs on a conveyor.
I've been tinkering with find_blobs() and have had good success finding them when lighting conditions are consistent with the threshold (they usually aren't).
The biggest problem I am having is when two eggs are close to each other, it counts them as the same blob (because of the threshold I'm guessing).
Any tips anybody can give me on better ways to detect and distinguish oval(ish) objects?


My code is something like this:

Code: Select all

thresh = [(7, 100, -128, 127, -128, 127)]

def find_blobs(img):
    blobs = img.find_blobs(thresh)
    for b in blobs:
        if b.area() >= 3000 and b.area() <= 6000: # filter blob sizes
            
            # debug blob sizes
            img.draw_string(b.x(), b.y() -15, str(b.area()),color=(0, 255, 0), scale=1.5)
            img.draw_rectangle(b.rect(), color=(0, 255, 0))
User avatar
kwagyeman
Posts: 3715
Joined: Sun May 24, 2015 2:10 pm

Re: Egg Detection

Postby kwagyeman » Wed Nov 27, 2019 8:09 pm

The best thing to do would be to look to see if the blob is elongated and then just count it as two in that case. We have a method that returns an elongation score. Just use that and threshold the score to decide between counting a blob as 1 or 2.
Nyamekye,
TenaciousB333
Posts: 2
Joined: Mon Nov 04, 2019 8:08 pm

Re: Egg Detection

Postby TenaciousB333 » Wed Nov 27, 2019 9:59 pm

Thanks! I'll try that, I also considered using haar cascade or training a neural network but I think those might be slower (not that speed is necessary in this case).

Return to “Project Discussion”

Who is online

Users browsing this forum: No registered users and 2 guests