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

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

Compute disp min and disp max from triangulated and filtered matches

downsample(tab, resolution)

Downsample the image dataset

clustering_matches(triangulated_matches[, ...])

Filter triangulated matches

filter_point_cloud_matches(pd_cloud[, ...])

Filter triangulated matches

pandora_matches(left_image_object, right_image_object, ...)

Calculate the pandora matches

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

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.7, n_octave: int = 8, n_scale_per_octave: int = 3, peak_threshold: float = 4.0, edge_threshold: float = 10.0, magnification: float = 7.0, window_size: int = 2, backmatching: bool = True, disp_lower_bound=None, disp_upper_bound=None)[source]

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

  • window_size (int) – size of the window

  • 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.7, n_octave=8, n_scale_per_octave=3, peak_threshold=4.0, edge_threshold=10.0, magnification=7.0, window_size=2, backmatching=True, disp_lower_bound=None, disp_upper_bound=None)[source]

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

  • window_size (int) – size of the window

  • 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)[source]

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)[source]

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.compute_disp_min_disp_max(pd_cloud, orchestrator, disp_margin=0.1, pair_key=None, disp_to_alt_ratio=None)[source]

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

cars.applications.sparse_matching.sparse_matching_tools.downsample(tab, resolution)[source]

Downsample the image dataset

Parameters
  • tab (cars dataset) – the image dataset

  • resolution (float) – the resolution of the resampling

Returns

the downsampled image

Return type

cars dataset

cars.applications.sparse_matching.sparse_matching_tools.clustering_matches(triangulated_matches, connection_val=3.0, nb_pts_threshold=80, clusters_distance_threshold: float = None, filtered_elt_pos: bool = False)[source]

Filter triangulated matches

Parameters
  • pd_cloud (pandas Dataframe) – triangulated_matches

  • connection_val – distance to use to consider that two points are connected

  • nb_pts_threshold – number of points to use to identify small clusters to filter

  • clusters_distance_threshold – distance to use to consider if two points clusters are far from each other or not (set to None to deactivate this level of filtering)

  • filtered_elt_pos – if filtered_elt_pos is set to True, the removed points positions in their original epipolar images are returned, otherwise it is set to None

Returns

filtered_matches

Return type

pandas Dataframe

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

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.pandora_matches(left_image_object, right_image_object, corr_conf, disp_upper_bound, disp_lower_bound, resolution, disp_to_alt_ratio=None)[source]

Calculate the pandora matches

Parameters
  • left_image_object (cars dataset) – the left image dataset

  • right_image_object (cars dataset) – the right image dataset

  • corr_conf (dict) – the pandora configuration

  • resolution (int) – the resolution of the resampling

  • disp_to_alt_ratio (float) – disp to alti ratio used for performance map

Returns

matches and disparity_map

Return type

datasets