[][src]Function opencv::calib3d::find_fundamental_mat_mask

pub fn find_fundamental_mat_mask(
    points1: &dyn ToInputArray,
    points2: &dyn ToInputArray,
    mask: &mut dyn ToOutputArray,
    method: i32,
    ransac_reproj_threshold: f64,
    confidence: f64
) -> Result<Mat>

Calculates a fundamental matrix from the corresponding points in two images.

Parameters

  • 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.
  • @ref FM_7POINT for a 7-point algorithm. inline formula
  • @ref FM_8POINT for an 8-point algorithm. inline formula
  • @ref FM_RANSAC for the RANSAC algorithm. inline formula
  • @ref FM_LMEDS for the LMedS algorithm. inline formula
  • 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.
  • mask:[out] optional output mask
  • maxIters: The maximum number of robust method iterations.

The epipolar geometry is described by the following equation:

block formula

where inline formula is a fundamental matrix, inline formula and inline formula 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 ( inline formula 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. :

   // 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);

Overloaded parameters

C++ default parameters

  • method: FM_RANSAC
  • ransac_reproj_threshold: 3.
  • confidence: 0.99