:py:mod:`cars.applications.sparse_matching.sparse_matching_tools` ================================================================= .. py:module:: cars.applications.sparse_matching.sparse_matching_tools .. autoapi-nested-parse:: Sparse matching Sift module: contains sift sparse matching method Module Contents --------------- Functions ~~~~~~~~~ .. autoapisummary:: cars.applications.sparse_matching.sparse_matching_tools.euclidean_matrix_distance cars.applications.sparse_matching.sparse_matching_tools.compute_matches cars.applications.sparse_matching.sparse_matching_tools.dataset_matching cars.applications.sparse_matching.sparse_matching_tools.remove_epipolar_outliers cars.applications.sparse_matching.sparse_matching_tools.compute_disparity_range cars.applications.sparse_matching.sparse_matching_tools.compute_disp_min_disp_max cars.applications.sparse_matching.sparse_matching_tools.downsample cars.applications.sparse_matching.sparse_matching_tools.clustering_matches cars.applications.sparse_matching.sparse_matching_tools.filter_point_cloud_matches cars.applications.sparse_matching.sparse_matching_tools.pandora_matches cars.applications.sparse_matching.sparse_matching_tools.transform_triangulated_matches_to_dataframe cars.applications.sparse_matching.sparse_matching_tools.nan_ratio_func cars.applications.sparse_matching.sparse_matching_tools.confidence_filtering .. py:function:: 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 .. py:function:: 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) Compute matches between left and right Convention for masks: True is a valid pixel :param left: left image as numpy array :type left: np.ndarray :param right: right image as numpy array :type right: np.ndarray :param left_mask: left mask as numpy array :type left_mask: np.ndarray :param right_mask: right mask as numpy array :type right_mask: np.ndarray :param left_origin: left image origin in the full image :type left_origin: [float, float] :param right_origin: right image origin in the full image :type right_origin: [float, float] :param matching_threshold: threshold for the ratio to nearest second match :type matching_threshold: float :param n_octave: the number of octaves of the DoG scale space :type n_octave: int :param n_scale_per_octave: the nb of levels / octave of the DoG scale space :type n_scale_per_octave: int :param peak_threshold: the peak selection threshold :type peak_threshold: float :param edge_threshold: the edge selection threshold :type edge_threshold: float :param magnification: set the descriptor magnification factor :type magnification: float :param window_size: size of the window :type window_size: int :param backmatching: also check that right vs. left gives same match :type backmatching: bool :return: matches :rtype: numpy buffer of shape (nb_matches,4) .. py:function:: 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) Compute sift matches between two datasets produced by stereo.epipolar_rectify_images :param ds1: Left image dataset :type ds1: xarray.Dataset as produced by stereo.epipolar_rectify_images :param ds2: Right image dataset :type ds2: xarray.Dataset as produced by stereo.epipolar_rectify_images :param matching_threshold: threshold for the ratio to nearest second match :type matching_threshold: float :param n_octave: the number of octaves of the DoG scale space :type n_octave: int :param n_scale_per_octave: the nb of levels / octave of the DoG scale space :type n_scale_per_octave: int :param peak_threshold: the peak selection threshold :type peak_threshold: int :param edge_threshold: the edge selection threshold. :param magnification: set the descriptor magnification factor :type magnification: float :param window_size: size of the window :type window_size: int :param backmatching: also check that right vs. left gives same match :type backmatching: bool :return: matches :rtype: numpy buffer of shape (nb_matches,4) .. py:function:: 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 :param matches: the [4,N] matches array :type matches: numpy array :param percent: the quantile to remove at each extrema :type percent: float :return: the filtered match array :rtype: numpy array .. py:function:: compute_disparity_range(matches, percent=0.1) This function will compute the disparity range from matches by filtering percent outliers :param matches: the [4,N] matches array :type matches: numpy array :param percent: the quantile to remove at each extrema (in %) :type percent: float :return: the disparity range :rtype: float, float .. py:function:: 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 :param pd_cloud: triangulated_matches :type pd_cloud: pandas Dataframe :param orchestrator: orchestrator used :type orchestrator: Orchestrator :param disp_margin: disparity margin :type disp_margin: float :param disp_to_alt_ratio: used for logging info :type disp_to_alt_ratio: float :return: disp min and disp max :rtype: float, float .. py:function:: downsample(tab, resolution, dim_max) Downsample the image dataset :param tab: the image dataset :type tab: cars dataset :param resolution: the resolution of the resampling :type resolution: float :param dim_max: the maximum dimensions :type dim_max: list :return: the downsampled image :rtype: cars dataset .. py:function:: clustering_matches(triangulated_matches, connection_val=3.0, nb_pts_threshold=80, clusters_distance_threshold: float = None, filtered_elt_pos: bool = False) Filter triangulated matches :param pd_cloud: triangulated_matches :type pd_cloud: pandas Dataframe :param connection_val: distance to use to consider that two points are connected :param nb_pts_threshold: number of points to use to identify small clusters to filter :param 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) :param 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 :return: filtered_matches :rtype: pandas Dataframe .. py:function:: filter_point_cloud_matches(pd_cloud, match_filter_knn=25, match_filter_constant=0, match_filter_mean_factor=1, match_filter_dev_factor=3) Filter triangulated matches :param pd_cloud: triangulated_matches :type pd_cloud: pandas Dataframe :param match_filter_knn: number of neighboors used to measure isolation of matches :type match_filter_knn: int :param match_filter_dev_factor: factor of deviation in the formula to compute threshold of outliers :type match_filter_dev_factor: float :return: disp min and disp max :rtype: float, float .. py:function:: pandora_matches(left_image_object, right_image_object, corr_conf, dim_max, conf_filtering, disp_upper_bound, disp_lower_bound, resolution) Calculate the pandora matches :param left_image_object: the left image dataset :type left_image_object: cars dataset :param right_image_object: the right image dataset :type right_image_object: cars dataset :param corr_conf: the pandora configuration :type corr_conf: dict :param dim_max: the maximum dimensions :type dim_max: list :param conf_filtering: True to filter the disp map :type conf_filtering: dict :param resolution: the resolution of the resampling :type resolution: int :return: matches and disparity_map :rtype: datasets .. py:function:: transform_triangulated_matches_to_dataframe(triangulated_matches) :param triangulated_matches: triangulated matches :type: cars_dataset .. py:function:: nan_ratio_func(window) " Calculate the number of nan in the window :param window: the window in the image .. py:function:: confidence_filtering(dataset, disp_map, requested_confidence, conf_filtering) Filter the disparity map by using the confidence :param dataset: the epipolar disparity map dataset :type dataset: cars dataset :param disp_map: the disparity map :type disp_map: numpy darray :param requested_confidence: the confidence to use :type requested_confidence: list :param conf_filtering: the confidence_filtering parameters :type conf_filtering: dict