recoverPose3
import { recoverPose3 } from '@banou/opencv-wasm'Use after await initOpenCV(). See the initialization and named imports guide.
Recovers the relative camera rotation and the translation from an estimated essential matrix and the corresponding points in two images, using chirality check. Returns the number of inliers that pass the check.
// Example. Estimation of fundamental matrix using the RANSAC algorithm
int point_count = 100;
vector<Point2f> points1(point_count);
vector<Point2f> points2(point_count);
// initialize the points here ...
for( int i = 0; i < point_count; i++ )
{
points1[i] = ...;
points2[i] = ...;
}
// cametra matrix with both focal lengths = 1, and principal point = (0, 0)
Mat cameraMatrix = Mat::eye(3, 3, CV_64F);
Mat E, R, t, mask;
E = findEssentialMat(points1, points2, cameraMatrix, RANSAC, 0.999, 1.0, mask);
recoverPose(E, points1, points2, cameraMatrix, R, t, mask);
recoverPose3(E: Mat, points1: Mat, points2: Mat, cameraMatrix: Mat, R: Mat, t: Mat, distanceThresh: number, mask: Mat, triangulatedPoints: Mat): number;3 available overloads
recoverPose3(E: Mat, points1: Mat, points2: Mat, cameraMatrix: Mat, R: Mat, t: Mat, distanceThresh: number): number;recoverPose3(E: Mat, points1: Mat, points2: Mat, cameraMatrix: Mat, R: Mat, t: Mat, distanceThresh: number, mask: Mat): number;recoverPose3(E: Mat, points1: Mat, points2: Mat, cameraMatrix: Mat, R: Mat, t: Mat, distanceThresh: number, mask: Mat, triangulatedPoints: Mat): number;EThe input essential matrix.
points1Array of N 2D points from the first image. The point coordinates should be floating-point (single or double precision).
points2Array of the second image points of the same size and format as points1.
cameraMatrixCamera intrinsic matrix
\cameramatrix{A}. Note that this function assumes that points1 and points2 are feature points from cameras with the same camera intrinsic matrix.ROutput destination, filled by the native operation. Output rotation matrix. Together with the translation vector, this matrix makes up a tuple that performs a change of basis from the first camera's coordinate system to the second camera's coordinate system. Note that, in general, t can not be used for this tuple, see the parameter description below.
tOutput destination, filled by the native operation. Output translation vector. This vector is obtained by
decomposeEssentialMatand therefore is only known up to scale, i.e. t is the direction of the translation vector and has unit length.distanceThreshthreshold distance which is used to filter out far away points (i.e. infinite points).
maskInput/output value, modified by the native operation. Input/output mask for inliers in points1 and points2. If it is not empty, then it marks inliers in points1 and points2 for the given essential matrix E. Only these inliers will be used to recover pose. In the output mask only inliers which pass the chirality check.
triangulatedPointsOutput destination, filled by the native operation. 3D points which were reconstructed by triangulation.
This function differs from the one above that it outputs the triangulated 3D point that are used for the chirality check.
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.