Circle Detection and Differentiating circle size

Discussion related to "under the hood" OpenMV topics.
21tlte
Posts: 5
Joined: Fri Jul 13, 2018 11:30 am

Circle Detection and Differentiating circle size

Hi,
I want to use Circle Detection to detect circles, which I did. But the thing is that I want to detect the largest one out of for example 5 circles. Or at least get values for largest one. Can you help me in any way? If you can I would appreciate your help.

Thanks for your time.
kwagyeman
Posts: 2111
Joined: Sun May 24, 2015 2:10 pm

Re: Circle Detection and Differentiating circle size

Have you tried out the find_circles example under feature detection in the IDE? If so, you just have to choose the circle from the list of circle objects that has the largest radius. Please see the find circles example to get started.
Nyamekye,
21tlte
Posts: 5
Joined: Fri Jul 13, 2018 11:30 am

Re: Circle Detection and Differentiating circle size

I indeed was using that function for detecting circles. But I can't find that list you are talking about. Are you talking about set "c" and if you are talking about it isn't that set updated every time for loop is "updated"? But still thanks for your time.
kwagyeman
Posts: 2111
Joined: Sun May 24, 2015 2:10 pm

Re: Circle Detection and Differentiating circle size

Hi, the find_circles method returns a list of circle objects. If you want to get the max sized circle from that list you simply do:

Code: Select all

``````circles = img.find_circles(...)
if circles:
largest_circles = max(circles, key = lambda x: x.r())``````
Or something like that. Um, if you need help with the python code just google for how to find the largest object in a list of objects, etc using python.
Nyamekye,
21tlte
Posts: 5
Joined: Fri Jul 13, 2018 11:30 am

Re: Circle Detection and Differentiating circle size

Thank you for helping. Didn't know that!!
21tlte
Posts: 5
Joined: Fri Jul 13, 2018 11:30 am

Re: Circle Detection and Differentiating circle size

And is there a way for the camera to receive data or commands from UART and if it can, how??

Thanks!!
kwagyeman
Posts: 2111
Joined: Sun May 24, 2015 2:10 pm

Re: Circle Detection and Differentiating circle size

See the Examples -> Pixy Emulation -> UART Color Tracking script for UART control examples.
Nyamekye,
21tlte
Posts: 5
Joined: Fri Jul 13, 2018 11:30 am

Ok thanks!