Skip to content

minEnclosingConvexPolygon

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

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

ARGUMENTSpoints, polygon, k
FUNCTIONminEnclosingConvexPolygon
RETURN TYPEnumber
Call structure. A void return can still write to destination arguments. The parameter descriptions define inputs, outputs and ownership.

Finds a convex polygon of minimum area enclosing a 2D point set and returns its area.

This function takes a given set of 2D points and finds the enclosing polygon with k vertices and minimal area. It takes the set of points and the parameter k as input and returns the area of the minimal enclosing polygon.

The Implementation is based on a paper by Aggarwal, Chang and Yap [Aggarwal1985]. They provide a \theta(n²log(n)log(k)) algorithm for finding the minimal convex polygon with k vertices enclosing a 2D convex polygon with n vertices (k < n). Since the #minEnclosingConvexPolygon function takes a 2D point set as input, an additional preprocessing step of computing the convex hull of the 2D point set is required. The complexity of the #convexHull function is O(n log(n)) which is lower than \theta(n²log(n)log(k)). Thus the overall complexity of the function is O(n²log(n)log(k)).

minEnclosingConvexPolygon(points: Mat, polygon: Mat, k: number): number;
points

Input vector of 2D points, stored in std::vector<> or Mat

polygon

Output destination, filled by the native operation. Output vector of 2D points defining the vertices of the enclosing polygon

k

Number of vertices of the output polygon

Returns

The number 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.