loading
 
COG of detected circles
Anonymous
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:

<head><version>1.7.10.5</version></head>
<Grayscale/>
<Contrast>
  <amount>-99</amount>
</Contrast>
<Sobel_Edge/>
<Circles>
  <statistics_image>Logitech QuickCam Chat</statistics_image>
  <max_radius>100000000</max_radius>
  <circle_color_index>9</circle_color_index>
  <min_radius>13</min_radius>
  <isolation>7</isolation>
  <solidity_index>16</solidity_index>
  <fill_circles>TRUE</fill_circles>
  <overlay_image>Current</overlay_image>
  <threshold> 0.00</threshold>
  <center_color_index>4</center_color_index>
</Circles>

Grayscale:
Contrast:
Edge:
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
next

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.

STeven.


program.robo
Thanks
Anonymous
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
kersny,

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.

STeven.

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