def test_infinite_distances(): x = np.array([1, 1, 0]) l = np.array([0, 1, 0]) assert_equals(evaluation.distance_point_to_line(x, l), np.finfo(float).max) x = np.array([1, 1, -7]) l = np.array([0, 0, 2.3]) assert_equals(evaluation.distance_point_to_line(x, l), np.finfo(float).max)
def test_finite_distances(): x = np.array([1, 1, 1]) l = np.array([0, 1, 0]) assert_equals(evaluation.distance_point_to_line(x, l), 1) x = np.array([-1, -1, -1]) l = np.array([0, 1, 0]) assert_equals(evaluation.distance_point_to_line(x, l), 1) x = np.array([1, 1, 1]) l = np.array([3, 2, -1]) assert_equals(evaluation.distance_point_to_line(x, l), 4 / np.sqrt(13))
def filter_matches_epipolar_constraint(F, matches, thresh): """ Discards matches that are not consistent with the epipolar constraint. Args: F: fundamental matrix matches: list of pairs of 2D points, stored as a Nx4 numpy array thresh: maximum accepted distance between a point and its matched epipolar line Returns: the list of matches that satisfy the constraint. It is a sub-list of the input list. """ out = [] for match in matches: x = np.array([match[0], match[1], 1]) xx = np.array([match[2], match[3], 1]) d1 = evaluation.distance_point_to_line(x, np.dot(F.T, xx)) d2 = evaluation.distance_point_to_line(xx, np.dot(F, x)) if max(d1, d2) < thresh: out.append(match) return np.array(out)