//fit an ellipse and get goodness of fit rRect = fitEllipse( Coords);
double angle = rRect.angle/180*Pi; Point2f Center = rRect.center; Size2f Sz = rRect.size;
g_GOF = 0; //Goodness Of Fit, the smaller the better double posx, posy; for(int i = 0; i < 32; i++){ posx = (Coords[i].x - Center.x) * cos(-angle) - (Coords[i].y- Center.y) * sin(-angle); posy = (Coords[i].x - Center.x) * sin(-angle) + (Coords[i].y- Center.y) * cos(-angle); g_GOF += abs( posx/Sz.widthposx/Sz.width + posy/Sz.heightposy/Sz.height - 0.25); }
//this works very well but comments are appreciated