Skip to content

findFundamentalMat

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

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

example: samples/cpp/snippets/epipolar_lines.cpp An example using the findFundamentalMat function Calculates a fundamental matrix from the corresponding points in two images.

    // 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] = ...;
    }

    Mat fundamental_matrix =
     findFundamentalMat(points1, points2, FM_RANSAC, 3, 0.99);
findFundamentalMat(points1: Mat, points2: Mat, method: number, ransacReprojThreshold: number, confidence: number, maxIters: number, mask: Mat): Mat;
2 available overloads
findFundamentalMat(points1: Mat, points2: Mat, method: number, ransacReprojThreshold: number, confidence: number, maxIters: number): Mat;
findFundamentalMat(points1: Mat, points2: Mat, method: number, ransacReprojThreshold: number, confidence: number, maxIters: number, mask: Mat): Mat;
points1

Array of N points from the first image. The point coordinates should be floating-point (single or double precision).

points2

Array of the second image points of the same size and format as points1 .

method

Method for computing a fundamental matrix.

  • FM_7POINT for a 7-point algorithm. N = 7
  • FM_8POINT for an 8-point algorithm. N \ge 8
  • FM_RANSAC for the RANSAC algorithm. N \ge 8
  • FM_LMEDS for the LMedS algorithm. N \ge 8
ransacReprojThreshold

Parameter used only for RANSAC. It is the maximum distance from a point to an epipolar line in pixels, beyond which the point is considered an outlier and is not used for computing the final fundamental matrix. It can be set to something like 1-3, depending on the accuracy of the point localization, image resolution, and the image noise.

confidence

Parameter used for the RANSAC and LMedS methods only. It specifies a desirable level of confidence (probability) that the estimated matrix is correct.

maxIters

The maximum number of robust method iterations.

The epipolar geometry is described by the following equation:

[p_2; 1]^T F [p_1; 1] = 0

where F is a fundamental matrix, p_1 and p_2 are corresponding points in the first and the second images, respectively.

The function calculates the fundamental matrix using one of four methods listed above and returns the found fundamental matrix. Normally just one matrix is found. But in case of the 7-point algorithm, the function may return up to 3 solutions ( 9 \times 3 matrix that stores all 3 matrices sequentially).

The calculated fundamental matrix may be passed further to #computeCorrespondEpilines that finds the epipolar lines corresponding to the specified points. It can also be passed to #stereoRectifyUncalibrated to compute the rectification transformation. :

mask

Output destination, filled by the native operation. optional output mask

Returns

The Mat result. 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.