COG of detected circles
17 year
I was wondering if there was a way to find the center of gravity of individual circles in an image. Here is my circle detection code:

  <statistics_image>Logitech QuickCam Chat</statistics_image>
  <threshold> 0.00</threshold>

Circle Fill:
Anonymous 17 year
Yes, there is. The center of gravity of a circle is always its center of circle. You already have that information in your code above as a circle array. You can use the following code to print out all the centers ... and can extend it to write it to disk or using the Loading/Saving->Write_Variables module by select the CIRCLE variable.

In a VBScript module you would use

circles = GetArrayVariable("CIRCLES")
for i = 0 to ubound(circles)-1 step 13
  write circles(i) & ":" & circles(i+1) & vbCRLF

which prints out the first two values in the circles array for each circle found. See the circles doc for more information about other values that are available for detected circles.

Below is you robofile with the VBScript code above.


17 year
Thanks for the code, it displays the variables nicely. Now I would like to just take the top x and y  values from the table and use them for some math. Is there any simple way to do this?
Anonymous 17 year

What do you mean by the top x and y values? Do you mean the topmost entry? Or the top 10 entries? This can be done simply by accessing the first values directly:

write circles(0) & ":" & circles(1)

would print out the top values. You can then use VBScript to do some calculations on the values or save those values to disk, distribute then via the API, etc.


This forum thread has been closed due to inactivity (more than 4 months) or number of replies (more than 50 messages). Please start a New Post and enter a new forum thread with the appropriate title.

 New Post   Forum Index