convexHull
import { convexHull } from '@banou/opencv-wasm'Use after await initOpenCV(). See the initialization and named imports guide.
example: samples/cpp/geometry.cpp An example program illustrates the use of cv::convexHull, cv::fitEllipse, cv::minEnclosingTriangle, cv::minEnclosingCircle and cv::minAreaRect. Finds the convex hull of a point set.
The function cv::convexHull finds the convex hull of a 2D point set using the Sklansky's algorithm [Sklansky82] that has O(N logN) complexity in the current implementation.
Note: points and hull should be different arrays, inplace processing isn't supported.
Check tutorial_hull "the corresponding tutorial" for more details.
useful links:
https://www.learnopencv.com/convex-hull-using-opencv-in-python-and-c/
convexHull(points: Mat, hull: Mat, clockwise: boolean, returnPoints: boolean): void;3 available overloads
convexHull(points: Mat, hull: Mat): void;convexHull(points: Mat, hull: Mat, clockwise: boolean): void;convexHull(points: Mat, hull: Mat, clockwise: boolean, returnPoints: boolean): void;pointsInput 2D point set, stored in std::vector or Mat.
hullOutput destination, filled by the native operation. Output convex hull. It is either an integer vector of indices or vector of points. In the first case, the hull elements are 0-based indices of the convex hull points in the original array (since the set of convex hull points is a subset of the original point set). In the second case, hull elements are the convex hull points themselves.
clockwiseOrientation flag. If it is true, the output convex hull is oriented clockwise. Otherwise, it is oriented counter-clockwise. The assumed coordinate system has its X axis pointing to the right, and its Y axis pointing upwards.
returnPointsOperation flag. In case of a matrix, when the flag is true, the function returns convex hull points. Otherwise, it returns indices of the convex hull points. When the output array is std::vector, the flag is ignored, and the output depends on the type of the vector: std::vector<int> implies returnPoints=false, std::vector<Point> implies returnPoints=true.
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.