Differentiating blob size

Discussion related to "under the hood" OpenMV topics.
Posts: 5
Joined: Tue Apr 03, 2018 7:57 am

Differentiating blob size

Postby andrijaadamovic » Mon Jun 04, 2018 3:24 am

Hello there.

If I have two same colored blobs, how can I detecting which one is bigger and send it's data(x,y width, height) to an arduino so it can be processed by my robot.

Have a nice day, Andrija.
Posts: 85
Joined: Tue May 29, 2018 4:15 am

Re: Differentiating blob size

Postby OutoftheBOTS » Mon Jun 04, 2018 4:16 am

Hopefully I can help you here.

something like this should find the biggest rect blob

Code: Select all

img = sensor.snapshot()
biggest = [0,0,0,0]
for blob in img.find_blobs([threshold], pixels_threshold=100, area_threshold=100, merge=True, margin=10):
   current = blob.rect()
   if current[2] * current[3] > biggest[2] * biggest[3]: biggest = current
I would image the easiest way to send this data to the Ardunio would be via UART and you would have serialize the data as a stream of 4 unsigned short int like this

Code: Select all

from ustruct import pack
packed_data = pack('HHHH', biggest)

Return to “Technical Discussion”

Who is online

Users browsing this forum: No registered users and 7 guests