1 | initial version |
This should be possible. fitEllipse will return a RotatedRect type, which contains
Using the center and angle, you re-center and un-rotate your points:
Your points will be centered at (0,0).
Now, if your points are truly ellipse then they should fit the ellipse equation closely:
float a = size.width * 0.5;
float b = size.height * 0.5;
x^2/a^2 + y^2/b^2 = 1
a and b might be swapped depending on the convention. Count how many points are "close" to 1, based on some experimental threshold. Or you can try something more sophisticated like finding the nearest distance to an ellipse in pixels (I have no idea what the formula is).