estimateAffinePartial2D
import { estimateAffinePartial2D } from '@banou/opencv-wasm'Use after await initOpenCV(). See the initialization and named imports guide.
Computes an optimal limited affine transformation with 4 degrees of freedom between two 2D point sets.
Note: The RANSAC method can handle practically any ratio of outliers but need a threshold to distinguish inliers from outliers. The method LMeDS does not need any threshold but it works correctly only when there are more than 50% of inliers.
See: estimateAffine2D, getAffineTransform
estimateAffinePartial2D(from_: Mat, to: Mat, inliers: Mat, method: number, ransacReprojThreshold: number, maxIters: number, confidence: number, refineIters: number): Mat;7 available overloads
estimateAffinePartial2D(from_: Mat, to: Mat): Mat;estimateAffinePartial2D(from_: Mat, to: Mat, inliers: Mat): Mat;estimateAffinePartial2D(from_: Mat, to: Mat, inliers: Mat, method: number): Mat;estimateAffinePartial2D(from_: Mat, to: Mat, inliers: Mat, method: number, ransacReprojThreshold: number): Mat;estimateAffinePartial2D(from_: Mat, to: Mat, inliers: Mat, method: number, ransacReprojThreshold: number, maxIters: number): Mat;estimateAffinePartial2D(from_: Mat, to: Mat, inliers: Mat, method: number, ransacReprojThreshold: number, maxIters: number, confidence: number): Mat;estimateAffinePartial2D(from_: Mat, to: Mat, inliers: Mat, method: number, ransacReprojThreshold: number, maxIters: number, confidence: number, refineIters: number): Mat;from_First input 2D point set.
toSecond input 2D point set.
inliersOutput destination, filled by the native operation. Output vector indicating which points are inliers.
methodRobust method used to compute transformation. The following methods are possible:
RANSAC- RANSAC-based robust methodLMEDS- Least-Median robust method RANSAC is the default method.
ransacReprojThresholdMaximum reprojection error in the RANSAC algorithm to consider a point as an inlier. Applies only to RANSAC.
maxItersThe maximum number of robust method iterations.
confidenceConfidence level, between 0 and 1, for the estimated transformation. Anything between 0.95 and 0.99 is usually good enough. Values too close to 1 can slow down the estimation significantly. Values lower than 0.8-0.9 can result in an incorrectly estimated transformation.
refineItersMaximum number of iterations of refining algorithm (Levenberg-Marquardt). Passing 0 will disable refining, so the output matrix will be output of robust method.
Output 2D affine transformation (4 degrees of freedom) matrix 2 \times 3 or
empty matrix if transformation could not be estimated.
The function estimates an optimal 2D affine transformation with 4 degrees of freedom limited to combinations of translation, rotation, and uniform scaling. Uses the selected algorithm for robust estimation.
The computed transformation is then refined further (using only inliers) with the Levenberg-Marquardt method to reduce the re-projection error even more.
Estimated transformation matrix is:
\begin{bmatrix} \cos(\theta) \cdot s & -\sin(\theta) \cdot s & t_x \\
\sin(\theta) \cdot s & \cos(\theta) \cdot s & t_y
\end{bmatrix}
Where \theta is the rotation angle, s the scaling factor and t_x, t_y are
translations in x, y axes respectively. Release returned native handles with using or delete(), including handles nested in results.
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.