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:
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))