posted by 심재형 2017. 11. 15. 13:14

fitEllipse

Fits an ellipse around a set of 2D points.

C++: RotatedRect fitEllipse(InputArray points)
Python: cv2.fitEllipse(points) → retval
C: CvBox2D cvFitEllipse2(const CvArr* points)
Python: cv.FitEllipse2(points) → Box2D
Parameters:points –

Input 2D point set, stored in:

  • std::vector<> or Mat (C++ interface)
  • CvSeq* or CvMat* (C interface)
  • Nx2 numpy array (Python interface)

The function calculates the ellipse that fits (in a least-squares sense) a set of 2D points best of all. It returns the rotated rectangle in which the ellipse is inscribed. The algorithm [Fitzgibbon95] is used. Developer should keep in mind that it is possible that the returned ellipse/rotatedRect data contains negative indices, due to the data points being close to the border of the containing Mat element.

Note

  • An example using the fitEllipse technique can be found at opencv_source_code/samples/cpp/fitellipse.cpp