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!
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
Post a Comment