c# - AForge ShapeCheker.IsCircle method -


well i'm using simpleshapechecker.iscircle method detect pupil. work fine, when sides pupil turns oval/ellipse shape. there method detect ovals?, or there way "relax" iscircle() method?

thanks

unfurtunately in aforge there not isoval() function.

but can take @ source code of shape checker!

https://code.google.com/p/aforge/source/browse/trunk/sources/math/geometry/simpleshapechecker.cs?r=1402

you can see iscircle() function , modify see if oval or not.

this function:

public bool iscircle( list<intpoint> edgepoints, out point center, out float radius )         {             // make sure have @ least 8 points curcle shape             if ( edgepoints.count < 8 )             {                 center = new point( 0, 0 );                 radius = 0;                 return false;             }              // bounding rectangle of points list             intpoint minxy, maxxy;             pointscloud.getboundingrectangle( edgepoints, out minxy, out maxxy );             // cloud's size             intpoint cloudsize = maxxy - minxy;             // calculate center point             center = minxy + (point) cloudsize / 2;              radius = ( (float) cloudsize.x + cloudsize.y ) / 4;              // calculate mean distance between provided edge points , estimated circle’s edge             float meandistance = 0;              ( int = 0, n = edgepoints.count; < n; i++ )             {                 meandistance += (float) math.abs( center.distanceto( edgepoints[i] ) - radius );             }             meandistance /= edgepoints.count;              float maxditance = math.max( minacceptabledistortion,                 ( (float) cloudsize.x + cloudsize.y ) / 2 * relativedistortionlimit );              return ( meandistance <= maxditance );         } 

maybe if play minacceptabledistortion variable, can detect ovals too!

hope helped.


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -