moments
import { moments } from '@banou/opencv-wasm'Use after await initOpenCV(). See the initialization and named imports guide.
Calculates all of the moments up to the third order of a polygon or rasterized shape.
The function computes moments, up to the 3rd order, of a vector shape or a rasterized shape. The results are returned in the structure cv::Moments.
Note: Only applicable to contour moments calculations from Python bindings: Note that the numpy type for the input array should be either np.int32 or np.float32.
Note: For contour-based moments, the zeroth-order moment m00 represents
the contour area.
If the input contour is degenerate (for example, a single point or all points
are collinear), the area is zero and therefore m00 == 0.
In this case, the centroid coordinates (m10/m00, m01/m00) are undefined
and must be handled explicitly by the caller.
A common workaround is to compute the center using cv::boundingRect() or by averaging the input points.
See: contourArea, arcLength
moments(array: Mat, binaryImage: boolean): Moments;2 available overloads
moments(array: Mat): Moments;moments(array: Mat, binaryImage: boolean): Moments;arraySingle channel raster image (CV_8U, CV_16U, CV_16S, CV_32F, CV_64F) or an array (
1 \times NorN \times 1) of 2D points (Point or Point2f).binaryImageIf it is true, all non-zero image pixels are treated as 1's. The parameter is used for images only.
moments.
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.