Beispiel #1
0
def two_view_reconstruction_rotation_only(p1, p2, camera1, camera2, threshold):
    b1 = multiview.pixel_bearings(p1, camera1)
    b2 = multiview.pixel_bearings(p2, camera2)
    t = np.zeros(3)

    R = pyopengv.relative_pose_ransac_rotation_only(b1, b2, 1 - np.cos(threshold), 1000)
    inliers = _two_view_reconstruction_rotation_only_inliers(b1, b2, R, threshold)

    # R = pyopengv.relative_pose_rotation_only(b1[inliers], b2[inliers])
    # inliers = _two_view_reconstruction_rotation_only_inliers(b1, b2, R, threshold)

    return cv2.Rodrigues(R.T)[0].ravel(), inliers
Beispiel #2
0
def two_view_reconstruction_rotation_only(p1, p2, camera1, camera2, threshold):
    b1 = multiview.pixel_bearings(p1, camera1)
    b2 = multiview.pixel_bearings(p2, camera2)
    t = np.zeros(3)

    R = pyopengv.relative_pose_ransac_rotation_only(b1, b2,
                                                    1 - np.cos(threshold),
                                                    1000)
    inliers = _two_view_reconstruction_rotation_only_inliers(
        b1, b2, R, threshold)

    # R = pyopengv.relative_pose_rotation_only(b1[inliers], b2[inliers])
    # inliers = _two_view_reconstruction_rotation_only_inliers(b1, b2, R, threshold)

    return cv2.Rodrigues(R.T)[0].ravel(), inliers
Beispiel #3
0
def robust_match_calibrated(p1, p2, camera1, camera2, matches, config):
    '''Computes robust matches by estimating the Essential matrix via RANSAC.
    '''

    if len(matches) < 8:
        return np.array([])

    p1 = p1[matches[:, 0]][:, :2].copy()
    p2 = p2[matches[:, 1]][:, :2].copy()
    b1 = multiview.pixel_bearings(p1, camera1)
    b2 = multiview.pixel_bearings(p2, camera2)

    threshold = config['robust_matching_threshold']
    T = pyopengv.relative_pose_ransac(b1, b2, "STEWENIUS", 1 - np.cos(threshold), 1000)

    inliers = compute_inliers_bearings(b1, b2, T)

    return matches[inliers]
Beispiel #4
0
def robust_match_calibrated(p1, p2, camera1, camera2, matches, config):
    '''Computes robust matches by estimating the Essential matrix via RANSAC.
    '''

    if len(matches) < 8:
        return np.array([])

    p1 = p1[matches[:, 0]][:, :2].copy()
    p2 = p2[matches[:, 1]][:, :2].copy()
    b1 = multiview.pixel_bearings(p1, camera1)
    b2 = multiview.pixel_bearings(p2, camera2)

    threshold = config['robust_matching_threshold']
    T = pyopengv.relative_pose_ransac(b1, b2, "STEWENIUS",
                                      1 - np.cos(threshold), 1000)

    inliers = compute_inliers_bearings(b1, b2, T)

    return matches[inliers]
Beispiel #5
0
def two_view_reconstruction(p1, p2, camera1, camera2, threshold):
    b1 = multiview.pixel_bearings(p1, camera1)
    b2 = multiview.pixel_bearings(p2, camera2)

    # Note on threshold:
    # See opengv doc on thresholds here: http://laurentkneip.github.io/opengv/page_how_to_use.html
    # Here we arbitrarily assume that the threshold is given for a camera of focal length 1
    # Also arctan(threshold) \approx threshold since threshold is small
    T = run_relative_pose_ransac(b1, b2, "STEWENIUS", 1 - np.cos(threshold), 1000)
    R = T[:, :3]
    t = T[:, 3]
    inliers = _two_view_reconstruction_inliers(b1, b2, R, t, threshold)

    T = run_relative_pose_optimize_nonlinear(b1[inliers], b2[inliers], t, R)
    R = T[:, :3]
    t = T[:, 3]
    inliers = _two_view_reconstruction_inliers(b1, b2, R, t, threshold)

    return cv2.Rodrigues(R.T)[0].ravel(), -R.T.dot(t), inliers
Beispiel #6
0
def two_view_reconstruction(p1, p2, camera1, camera2, threshold):
    b1 = multiview.pixel_bearings(p1, camera1)
    b2 = multiview.pixel_bearings(p2, camera2)

    # Note on threshold:
    # See opengv doc on thresholds here: http://laurentkneip.github.io/opengv/page_how_to_use.html
    # Here we arbitrarily assume that the threshold is given for a camera of focal length 1
    # Also arctan(threshold) \approx threshold since threshold is small
    T = run_relative_pose_ransac(b1, b2, "STEWENIUS", 1 - np.cos(threshold),
                                 1000)
    R = T[:, :3]
    t = T[:, 3]
    inliers = _two_view_reconstruction_inliers(b1, b2, R, t, threshold)

    T = run_relative_pose_optimize_nonlinear(b1[inliers], b2[inliers], t, R)
    R = T[:, :3]
    t = T[:, 3]
    inliers = _two_view_reconstruction_inliers(b1, b2, R, t, threshold)

    return cv2.Rodrigues(R.T)[0].ravel(), -R.T.dot(t), inliers