Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

This should be possible. fitEllipse will return a RotatedRect type, which contains

  • Point2f center
  • Size2f size
  • float angle

Using the center and angle, you re-center and un-rotate your points:

  1. points = points - center
  2. points = inv_R * 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).