miop.epipolar_geometry

Classes

EpipolarGeometry([numSamples, kappa, ...])

class miop.epipolar_geometry.EpipolarGeometry(numSamples=1000, kappa=2.5, stdFixed=1.0, searchRange=200, bucketing=False, stdEstimation='adaptive', nSets=1, verbose=False, cost_function='sampson', robust_method='MLESAC')[source]

Bases: DAGNode

compute_costs_thresholds(pts1, pts2, Farr)[source]

Compute the cost values and inlier threshold.

Parameters:
  • pts1 (ndarray of shape (n, 2)) – Points from the first image.

  • pts2 (ndarray of shape (n, 2)) – Points from the second image.

  • Farr (ndarray of shape (numSamples, 3, 3)) – Fundamental matrices.

Returns:

  • errorArr (ndarray) – Error array (numSamples x numPoints).

  • std (float) – Estimated or fixed standard deviation.

  • threshold (float) – Inlier threshold.

  • leastMedian (float) – Minimum median value across all samples.

compute_standard_deviation(numMatches, leastMedian)[source]

Compute standard deviation and inlier threshold.

Parameters:
  • numMatches (int) – Number of matches.

  • leastMedian (float) – Least median of residuals.

Returns:

  • std (float) – Estimated or fixed standard deviation.

  • threshold (float) – Threshold for inlier classification.

estimate_robust_affine_fundamental_matrix(pts1, pts2, numSamples)[source]

Estimate the best fundamental matrices using robust methods.

Parameters:
  • pts1 (ndarray of shape (n, 2)) – Points from the first image.

  • pts2 (ndarray of shape (n, 2)) – Points from the second image.

  • numSamples (int) – Number of models to estimate.

Returns:

setsIn – List of tuples (inPts1, inPts2, F, cost, std) for the best fundamental matrices.

Return type:

list

eval(matches)[source]

Perform robust estimation of fundamental matrices for multiple stereo pairs.

Parameters:

matches (list of tuples) – Each tuple contains matched 2D points (pts1, pts2) for one stereo pair.

Returns:

A list of dictionaries or a list of lists of dictionaries containing: - ‘pts1’, ‘pts2’: inlier point coordinates - ‘F’: estimated fundamental matrix - ‘cost’: model cost - ‘std’: standard deviation of residuals

Return type:

list

lmeds(Farr, pts1, pts2)[source]

Estimate the fundamental matrix using the Least Median of Squares (LMedS) method.

Parameters:
  • Farr (ndarray of shape (numSamples, 3, 3)) – Sampled fundamental matrices.

  • pts1 (ndarray of shape (n, 2)) – Points from the first image.

  • pts2 (ndarray of shape (n, 2)) – Points from the second image.

Returns:

setsIn – List of tuples (inPts1, inPts2, F, cost, std) sorted by cost.

Return type:

list

max_expectation_gamma_robust(std, errorArr, numMatches, vDist, iters=5)[source]

Estimate mixture parameter gamma via EM for MLESAC.

Parameters:
  • std (float) – Estimated standard deviation.

  • errorArr (ndarray) – Error values (squared distances).

  • numMatches (int) – Number of matches.

  • vDist (float) – Search range (for uniform outlier model).

  • iters (int, optional) – Number of EM iterations (default is 5).

Returns:

gamma – Mixture parameter gamma values.

Return type:

ndarray of shape (numSamples, 1)

mlesac(Farr, pts1, pts2)[source]

Estimate the fundamental matrix using the MLESAC algorithm.

Parameters:
  • Farr (ndarray of shape (numSamples, 3, 3)) – Sampled fundamental matrices.

  • pts1 (ndarray of shape (n, 2)) – Points from the first image.

  • pts2 (ndarray of shape (n, 2)) – Points from the second image.

Returns:

setsIn – List of tuples (inPts1, inPts2, F, cost, std) sorted by likelihood.

Return type:

list

msac(Farr, pts1, pts2)[source]

Estimate the fundamental matrix using the MSAC algorithm.

Parameters:
  • Farr (ndarray of shape (numSamples, 3, 3)) – Sampled fundamental matrices.

  • pts1 (ndarray of shape (n, 2)) – Points from the first image.

  • pts2 (ndarray of shape (n, 2)) – Points from the second image.

Returns:

setsIn – List of tuples (inPts1, inPts2, F, cost, std) sorted by cost.

Return type:

list

ransac(Farr, pts1, pts2)[source]

Estimate the fundamental matrix using RANSAC.

Parameters:
  • Farr (ndarray of shape (numSamples, 3, 3)) – Sampled fundamental matrices.

  • pts1 (ndarray of shape (n, 2)) – Points from the first image.

  • pts2 (ndarray of shape (n, 2)) – Points from the second image.

Returns:

setsIn – List of tuples (inPts1, inPts2, F, cost, std) sorted by inlier count.

Return type:

list

robust_sampson(Farr, pts1, pts2)[source]

Compute Sampson distances for each match and each fundamental matrix sample.

Parameters:
  • Farr (ndarray of shape (numSamples, 3, 3)) – Fundamental matrices.

  • pts1 (ndarray of shape (n, 3)) – Homogenized points from the first image.

  • pts2 (ndarray of shape (n, 3)) – Homogenized points from the second image.

Returns:

sampsonDist – Computed Sampson distances.

Return type:

ndarray of shape (numSamples, n)

single_affine_fundamental_matrix(matches)[source]

Estimate a single fundamental matrix from matched points.

Parameters:

matches (ndarray of shape (n, 4)) – Matched keypoints or points between two images. Each element of the array represents one corresponding point (x1, y1, x2, y2)

Returns:

F – The estimated affine fundamental matrix

Return type:

ndarray of shape (3, 3)

tensor_affine_fundamental_matrix(pts1, pts2, numSamples)[source]

Generate fundamental matrices using the affine gold standard algorithm.

Parameters:
  • pts1 (ndarray of shape (n, 2)) – Points from the first image.

  • pts2 (ndarray of shape (n, 2)) – Points from the second image.

  • numSamples (int) – Number of samples to compute.

Returns:

F – Fundamental matrices.

Return type:

ndarray of shape (numSamples, 3, 3)