cars.applications.sparse_matching.sparse_matching_tools

Sparse matching Sift module: contains sift sparse matching method

Module Contents

Functions

euclidean_matrix_distance(descr1, descr2)

Compute a matrix containing cross euclidean distance

compute_matches(left, right[, left_mask, right_mask, ...])

Compute matches between left and right

dataset_matching(ds1, ds2[, matching_threshold, ...])

Compute sift matches between two datasets

remove_epipolar_outliers(matches[, percent])

This function will filter the match vector

compute_disparity_range(matches[, percent])

This function will compute the disparity range

filter_point_cloud_matches(pd_cloud[, ...])

Filter triangulated matches

compute_disp_min_disp_max(pd_cloud, orchestrator[, ...])

Compute disp min and disp max from triangulated and filtered matches

cars.applications.sparse_matching.sparse_matching_tools.euclidean_matrix_distance(descr1: numpy.array, descr2: numpy.array)

Compute a matrix containing cross euclidean distance :param descr1: first keypoints descriptor :type descr1: numpy.ndarray :param descr2: second keypoints descriptor :type descr2: numpy.ndarray :return euclidean matrix distance :rtype: float

cars.applications.sparse_matching.sparse_matching_tools.compute_matches(left: numpy.ndarray, right: numpy.ndarray, left_mask: numpy.ndarray = None, right_mask: numpy.ndarray = None, left_origin: [float, float] = None, right_origin: [float, float] = None, matching_threshold: float = 0.6, n_octave: int = 8, n_scale_per_octave: int = 3, peak_threshold: float = 20.0, edge_threshold: float = 5.0, magnification: float = 2.0, backmatching: bool = True, disp_lower_bound=None, disp_upper_bound=None)

Compute matches between left and right Convention for masks: True is a valid pixel

Parameters
  • left (np.ndarray) – left image as numpy array

  • right (np.ndarray) – right image as numpy array

  • left_mask (np.ndarray) – left mask as numpy array

  • right_mask (np.ndarray) – right mask as numpy array

  • left_origin ([float, float]) – left image origin in the full image

  • right_origin ([float, float]) – right image origin in the full image

  • matching_threshold (float) – threshold for the ratio to nearest second match

  • n_octave (int) – the number of octaves of the DoG scale space

  • n_scale_per_octave (int) – the nb of levels / octave of the DoG scale space

  • peak_threshold (float) – the peak selection threshold

  • edge_threshold (float) – the edge selection threshold

  • magnification (float) – set the descriptor magnification factor

  • backmatching (bool) – also check that right vs. left gives same match

Returns

matches

Return type

numpy buffer of shape (nb_matches,4)

cars.applications.sparse_matching.sparse_matching_tools.dataset_matching(ds1, ds2, matching_threshold=0.6, n_octave=8, n_scale_per_octave=3, peak_threshold=20.0, edge_threshold=5.0, magnification=2.0, backmatching=True, disp_lower_bound=None, disp_upper_bound=None)

Compute sift matches between two datasets produced by stereo.epipolar_rectify_images

Parameters
  • ds1 (xarray.Dataset as produced by stereo.epipolar_rectify_images) – Left image dataset

  • ds2 (xarray.Dataset as produced by stereo.epipolar_rectify_images) – Right image dataset

  • matching_threshold (float) – threshold for the ratio to nearest second match

  • n_octave (int) – the number of octaves of the DoG scale space

  • n_scale_per_octave (int) – the nb of levels / octave of the DoG scale space

  • peak_threshold (int) – the peak selection threshold

  • edge_threshold – the edge selection threshold.

  • magnification (float) – set the descriptor magnification factor

  • backmatching (bool) – also check that right vs. left gives same match

Returns

matches

Return type

numpy buffer of shape (nb_matches,4)

cars.applications.sparse_matching.sparse_matching_tools.remove_epipolar_outliers(matches, percent=0.1)

This function will filter the match vector according to a quantile of epipolar error used for testing compute_disparity_range sparse method

Parameters
  • matches (numpy array) – the [4,N] matches array

  • percent (float) – the quantile to remove at each extrema

Returns

the filtered match array

Return type

numpy array

cars.applications.sparse_matching.sparse_matching_tools.compute_disparity_range(matches, percent=0.1)

This function will compute the disparity range from matches by filtering percent outliers

Parameters
  • matches (numpy array) – the [4,N] matches array

  • percent (float) – the quantile to remove at each extrema (in %)

Returns

the disparity range

Return type

float, float

cars.applications.sparse_matching.sparse_matching_tools.filter_point_cloud_matches(pd_cloud, matches_filter_knn=25, matches_filter_dev_factor=3)

Filter triangulated matches

Parameters
  • pd_cloud (pandas Dataframe) – triangulated_matches

  • matches_filter_knn (int) – number of neighboors used to measure isolation of matches

  • matches_filter_dev_factor (float) – factor of deviation in the formula to compute threshold of outliers

Returns

disp min and disp max

Return type

float, float

cars.applications.sparse_matching.sparse_matching_tools.compute_disp_min_disp_max(pd_cloud, orchestrator, disp_margin=0.1, pair_key=None, disp_to_alt_ratio=None)

Compute disp min and disp max from triangulated and filtered matches

Parameters
  • pd_cloud (pandas Dataframe) – triangulated_matches

  • orchestrator (Orchestrator) – orchestrator used

  • disp_margin (float) – disparity margin

  • disp_to_alt_ratio (float) – used for logging info

Returns

disp min and disp max

Return type

float, float