CentralCamera.points2F#

static CentralCamera.points2F(p1: ndarray, p2: ndarray, method: str = '8p', residual: bool = True, seed: int | None = None, **kwargs) list[source][source]#

Estimate fundamental matrix from corresponding points

Parameters:
  • p1 (ndarray(2,N)) – image plane points from first camera

  • p2 (ndarray(2,N)) – image plane points from second camera

  • method (str, optional) – algorithm ‘7p’, ‘8p’ [default], ‘ransac’, ‘lmeds’

  • residual (bool, optional) – also return the reprojection residual, defaults to True

  • seed (int, optional) – seed the RNG used by ‘ransac’/’lmeds’ for repeatable results, defaults to None (not seeded)

  • kwargs (dict, optional) –

    passed through to cv2.findFundamentalMat. ransacReprojThreshold (float, defaults to 3.0) applies only when method='ransac' – max distance in pixels from a point to its epipolar line for the point to still count as an inlier; method='lmeds' ignores it entirely (verified empirically – identical result regardless of value). confidence (float in (0,1), defaults to 0.99) and maxIters (int, defaults to 1000) apply to either method='ransac' or method='lmeds'method only ever selects one algorithm at a time (a combined “ransac+lmeds” method isn’t a real OpenCV feature; verified empirically that OR-ing the two method flags together doesn’t error, but silently reduces to plain LMedS – an implementation accident, not a documented hybrid mode). Defaults verified empirically 2026-08-16 (identical inlier masks with/without them explicit, same RNG seed) – not otherwise documented by the cv2 Python bindings. Same parameter set and defaults on OpenCV 4.10 and 5.0.

    Warning

    maxIters only works when ransacReprojThreshold and confidence are also given explicitly – passing only maxIters= hits a cv2.findFundamentalMat overload-resolution failure (a confusing low-level OpenCV error, not a clear Python one), since the 3-argument overload this method otherwise uses has no maxIters parameter at all.

Raises:

ValueError – fewer than the minimum number of point correspondences for method (7 for ‘7p’, 8 otherwise), or the points are too degenerate (eg. coplanar, collinear) for cv2.findFundamentalMat to estimate F from

Returns:

fundamental matrix and residual

Return type:

ndarray(3,3), float

Computes the fundamental matrix from two sets of corresponding image-plane points. Corresponding points are given by corresponding columns of p1 and p2.

Example:

>>> from machinevisiontoolbox import CentralCamera, mkgrid
>>> from spatialmath import SE3
>>> camera1 = CentralCamera(name="camera 1", f=0.002, imagesize=1000, rho=10e-6, pose=SE3.Tx(-0.1)*SE3.Ry(0.4))
>>> camera2 = CentralCamera(name="camera 2", f=0.002, imagesize=1000, rho=10e-6, pose=SE3.Tx(0.1)*SE3.Ry(-0.4))
>>> T_grid = SE3.Tz(1) * SE3.Rx(0.1) * SE3.Ry(0.2)
>>> P = mkgrid(3, 1.0, pose=T_grid)
>>> p1 = camera1.project_point(P)
>>> p2 = camera2.project_point(P);
>>> F, resid = CentralCamera.points2F(p1, p2)
>>> F
array([[-0.0001,  0.0005, -0.2083],
       [-0.0006, -0.    ,  0.2645],
       [ 0.3044, -0.3069,  1.    ]])
>>> resid
np.float64(2.2567392544778285e-06)
Seealso:

F E opencv.findFundamentalMat