(
    p1: np.ndarray,
    p2: np.ndarray,
    camera1: pygeometry.Camera,
    camera2: pygeometry.Camera,
    threshold: float,
    iterations: int,
    check_reversal: bool = False,
    reversal_ratio: float = 1.0,
)
return R, t, inliers, report
Reconstruct two views from point correspondences.

    These will try different reconstruction methods and return the
    results of the one with most inliers.

    Args:
        p1, p2: lists points in the images
        camera1, camera2: Camera models
        threshold: reprojection error threshold
        iterations: number of step for the non-linear refinement of the relative pose
        check_reversal: whether to check for Necker reversal ambiguity
        reversal_ratio: ratio of triangulated point between normal and reversed
                        configuration to consider a pair as being ambiguous

    Returns:
        rotation, translation and inlier list
Reconstruct two views from point correspondences.
Reconstruct two views from point correspondences .
def two_view_reconstruction_general(
    p1: np.ndarray,
    p2: np.ndarray,
    camera1: pygeometry.Camera,
    camera2: pygeometry.Camera,
    threshold: float,
    iterations: int,
    check_reversal: bool = False,
    reversal_ratio: float = 1.0,
) -> Tuple[Optional[np.ndarray], Optional[np.ndarray], List[int], Dict[str, Any]]:
    """Reconstruct two views from point correspondences.

    These will try different reconstruction methods and return the
    results of the one with most inliers.

    Args:
        p1, p2: lists points in the images
        camera1, camera2: Camera models
        threshold: reprojection error threshold
        iterations: number of step for the non-linear refinement of the relative pose
        check_reversal: whether to check for Necker reversal ambiguity
        reversal_ratio: ratio of triangulated point between normal and reversed
                        configuration to consider a pair as being ambiguous

    Returns:
        rotation, translation and inlier list
    """

    b1 = camera1.pixel_bearing_many(p1)
    b2 = camera2.pixel_bearing_many(p2)

    # Get 5-point relative motion
    T_robust = multiview.relative_pose_ransac(b1, b2, threshold, 1000, 0.999)
    R_robust = T_robust[:, :3]
    t_robust = T_robust[:, 3]
    R_5p, t_5p, inliers_5p = two_view_reconstruction_5pt(
        b1,
        b2,
        R_robust,
        t_robust,
        threshold,
        iterations,
        check_reversal,
        reversal_ratio,
    )
    valid_5pt = R_5p is not None and t_5p is not None

    # Compute plane-based relative-motion
    R_plane, t_plane, inliers_plane = two_view_reconstruction_plane_based(
        b1,
        b2,
        threshold,
    )
    valid_plane = R_plane is not None and t_plane is not None

    report: Dict[str, Any] = {
        "5_point_inliers": len(inliers_5p),
        "plane_based_inliers": len(inliers_plane),
    }

    if valid_5pt and len(inliers_5p) > len(inliers_plane):
        report["method"] = "5_point"
        R, t, inliers = R_5p, t_5p, inliers_5p
    elif valid_plane:
        report["method"] = "plane_based"
        R, t, inliers = R_plane, t_plane, inliers_plane
    else:
        report["decision"] = "Could not find initial motion"
        logger.info(report["decision"])
        R, t, inliers = None, None, []
    return R, t, inliers, report
def two_view_reconstruction_general ( p1 : np . ndarray , p2 : np . ndarray , camera1 : pygeometry . Camera , camera2 : pygeometry . Camera , threshold : float , iterations : int , check_reversal : bool = False , reversal_ratio : float = 1.0 , ) -> Tuple [ Optional [ np . ndarray ] , Optional [ np . ndarray ] , List [ int ] , Dict [ str , Any ] ] : b1 = camera1 . pixel_bearing_many ( p1 ) b2 = camera2 . pixel_bearing_many ( p2 ) # Get 5-point relative motion T_robust = multiview . relative_pose_ransac ( b1 , b2 , threshold , 1000 , 0.999 ) R_robust = T_robust [ : , : 3 ] t_robust = T_robust [ : , 3 ] R_5p , t_5p , inliers_5p = two_view_reconstruction_5pt ( b1 , b2 , R_robust , t_robust , threshold , iterations , check_reversal , reversal_ratio , ) valid_5pt = R_5p is not None and t_5p is not None # Compute plane-based relative-motion R_plane , t_plane , inliers_plane = two_view_reconstruction_plane_based ( b1 , b2 , threshold , ) valid_plane = R_plane is not None and t_plane is not None report : Dict [ str , Any ] = { "5_point_inliers" : len ( inliers_5p ) , "plane_based_inliers" : len ( inliers_plane ) , } if valid_5pt and len ( inliers_5p ) > len ( inliers_plane ) : report [ "method" ] = "5_point" R , t , inliers = R_5p , t_5p , inliers_5p elif valid_plane : report [ "method" ] = "plane_based" R , t , inliers = R_plane , t_plane , inliers_plane else : report [ "decision" ] = "Could not find initial motion" logger . info ( report [ "decision" ] ) R , t , inliers = None , None , [ ] return R , t , inliers , report