Skip to content

fitEllipse

geometryfunctionOpenCV 5.0.0
import { fitEllipse } from '@banou/opencv-wasm'

Use after await initOpenCV(). See the initialization and named imports guide.

ARGUMENTSpoints
FUNCTIONfitEllipse
RETURN TYPERotatedRect
Call structure. A void return can still write to destination arguments. The parameter descriptions define inputs, outputs and ownership.

Fits an ellipse around a set of 2D points.

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 first algorithm described by [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: Input point types are Point2i or Point2f and at least 5 points are required.

Note: getClosestEllipsePoints function can be used to compute the ellipse fitting error.

fitEllipse(points: Mat): RotatedRect;
points

Input 2D point set, stored in std::vector<> or Mat

Returns

The RotatedRect result.

These signatures describe this package. Upstream documentation can mention optional backends that are absent from this build. Check runtime compatibility before choosing a backend or file format.