cars.applications.dense_matching.dense_matching_wrappers ======================================================== .. py:module:: cars.applications.dense_matching.dense_matching_wrappers .. autoapi-nested-parse:: This module is responsible for the dense matching algorithms: - thus it creates a disparity map from a pair of images Functions --------- .. autoapisummary:: cars.applications.dense_matching.dense_matching_wrappers.get_margins cars.applications.dense_matching.dense_matching_wrappers.get_masks_from_pandora cars.applications.dense_matching.dense_matching_wrappers.add_disparity_grids cars.applications.dense_matching.dense_matching_wrappers.add_texture cars.applications.dense_matching.dense_matching_wrappers.add_edges cars.applications.dense_matching.dense_matching_wrappers.add_classification cars.applications.dense_matching.dense_matching_wrappers.compute_cropped_roi cars.applications.dense_matching.dense_matching_wrappers.create_disp_dataset cars.applications.dense_matching.dense_matching_wrappers.add_crop_info cars.applications.dense_matching.dense_matching_wrappers.estimate_right_classif_on_left cars.applications.dense_matching.dense_matching_wrappers.mask_left_classif_from_right_mask cars.applications.dense_matching.dense_matching_wrappers.merge_classif_left_right cars.applications.dense_matching.dense_matching_wrappers.add_confidence cars.applications.dense_matching.dense_matching_wrappers.to_safe_disp_grid cars.applications.dense_matching.dense_matching_wrappers.estimate_right_grid_disp cars.applications.dense_matching.dense_matching_wrappers.optimal_tile_size_pandora_plugin_libsgm cars.applications.dense_matching.dense_matching_wrappers.get_max_disp_from_opt_tile_size cars.applications.dense_matching.dense_matching_wrappers.nan_ratio_func cars.applications.dense_matching.dense_matching_wrappers.confidence_filtering Module Contents --------------- .. py:function:: get_margins(margin, disp_min, disp_max) Get margins for the dense matching steps :param margin: margins object :type margin: Margins :param disp_min: Minimum disparity :type disp_min: int :param disp_max: Maximum disparity :type disp_max: int :return: margins of the matching algorithm used .. py:function:: get_masks_from_pandora(disp: xarray.Dataset, compute_disparity_masks: bool, filter_incomplete_disparity_range: bool) -> Dict[str, numpy.ndarray] Get masks dictionary from the disparity map in output of pandora. :param disp: disparity map (pandora output) :param compute_disparity_masks: compute_disparity_masks activation status :return: masks dictionary .. py:function:: add_disparity_grids(output_dataset: xarray.Dataset, disp_min_grid: numpy.ndarray = None, disp_max_grid: numpy.ndarray = None) Add disparity min and max grids to dataset :param output_dataset: output dataset :param disp_min_grid: dense disparity map grid min :param disp_max_grid: dense disparity map grid max .. py:function:: add_texture(output_dataset: xarray.Dataset, texture: numpy.ndarray = None, color_type=None, band_im: list = None, texture_bands: list = None) Add image and image mask to dataset :param output_dataset: output dataset :param image: image array :param image_type: data type of pixels :param band_im: list of band names .. py:function:: add_edges(output_dataset: xarray.Dataset, ref_dataset: xarray.Dataset) Add image and image mask to dataset :param output_dataset: output dataset :param image: image array :param image_type: data type of pixels :param band_im: list of band names .. py:function:: add_classification(output_dataset: xarray.Dataset, classif: numpy.ndarray = None, band_classif: list = None) Add classification to dataset :param output_dataset: output dataset :param classif: classif array :param band_im: list of band names .. py:function:: compute_cropped_roi(current_margins, margins_to_keep, tile_roi, nb_rows, nb_cols) Compute cropped roi, with associated margins and :param current_margins: current dataset margins :type current_margins: list[int] :param margins_to_keep: margin to keep :type margins_to_keep: int :param nb_rows: number of current rows :type margins_to_keep: int :param tile_roi: roi without margin of tile :type tile_roi: list :param nb_cols: number of current cols :type nb_cols: int :return: (borders to use as roi, new dataset roi with margin, margin associated to roi) :rtype: tuple(list, list, list) .. py:function:: create_disp_dataset(disp: xarray.Dataset, ref_dataset: xarray.Dataset, secondary_dataset: xarray.Dataset, compute_disparity_masks: bool = False, disp_min_grid=None, disp_max_grid=None, cropped_range=None, margins_to_keep=0, classification_fusion_margin=-1, texture_bands=None, filter_incomplete_disparity_range=True) -> xarray.Dataset Create the disparity dataset. :param disp: disparity map (result of pandora) :param ref_dataset: reference dataset for the considered disparity map :param secondary_dataset: secondary dataset for the considered disparity map :param compute_disparity_masks: compute_disparity_masks activation status :param disp_min_grid: disparity min grid :param disp_max_grid: disparity max grid :param cropped_range: true if disparity range was cropped :type cropped_range: numpy array :param margins_to_keep: margin to keep after dense matching :type margins_to_keep: int :return: disparity dataset as used in cars .. py:function:: add_crop_info(disp_ds, cropped_range) Add crop info :param disp: disp xarray :param cropped_range: was cropped range, bool :return updated dataset .. py:function:: estimate_right_classif_on_left(right_classif, disp_map, disp_mask, disp_min, disp_max, classifiation_fusion_margin) Estimate right classif on left image :param right_classif: right classification :type right_classif: np ndarray :param disp_map: disparity map :type disp_map: np ndarray :param disp_mask: disparity mask :type disp_mask: np ndarray :param disp_min: disparity min :type disp_min: int :param disp_max: disparity max :type disp_max: int :return: right classif on left image :rtype: np nadarray .. py:function:: mask_left_classif_from_right_mask(left_classif, right_mask, disp_min, disp_max, classifiation_fusion_margin) Mask left classif with right mask. :param left_classif: right classification :type left_classif: np ndarray :param right_mask: right mask :type right_mask: np ndarray :param disp_min: disparity min :type disp_min: np.array type int :param disp_max: disparity max :type disp_max: np.array type int :return: masked left classif :rtype: np nadarray .. py:function:: merge_classif_left_right(left_classif, left_band_classif, right_classif, right_band_classif) Merge left and right classif :param left_classif: left classif :type left_classif: np nadarray :param left_band_classif: list of tag :type left_band_classif: list :param right_classif: left classif :type right_classif: np nadarray :param right_band_classif: list of tag :type right_band_classif: list :return: merged classif, merged tag list :rtype: np ndarray, list .. py:function:: add_confidence(output_dataset: xarray.Dataset, disp: xarray.Dataset) Add confidences to dataset :param output_dataset: output dataset :param disp: disp xarray .. py:function:: to_safe_disp_grid(grid_disp_min, grid_disp_max) Generate safe grids, with min < max for each point :param grid_disp_min: min disp grid :param grid_disp_max: max disp grid :return: grid_disp_min, grid_disp_max .. py:function:: estimate_right_grid_disp(disp_min_grid, disp_max_grid) Estimate right grid min and max. Correspond to the range of pixels that can be correlated from left -> right. If no left pixels can be associated to right, use global values :param disp_min_grid: left disp min grid :type disp_min_grid: numpy ndarray :param disp_max_grid: left disp max grid :type disp_max_grid: numpy ndarray :return: disp_min_right_grid, disp_max_right_grid :rtype: numpy ndarray, numpy ndarray .. py:function:: optimal_tile_size_pandora_plugin_libsgm(disp_min: int, disp_max: int, min_tile_size: int, max_tile_size: int, max_ram_per_worker: int, tile_size_rounding: int = 50, margin: int = 0) -> int Compute optimal tile size according to estimated memory usage (pandora_plugin_libsgm) Returned optimal tile size will be at least equal to tile_size_rounding. :param disp_min: Minimum disparity to explore :param disp_max: Maximum disparity to explore :param min_tile_size: Minimal tile size :param max_tile_size: Maximal tile size :param max_ram_per_worker: amount of RAM allocated per worker :param tile_size_rounding: Optimal tile size will be aligned to multiples of tile_size_rounding :param margin: margin to remove to the computed tile size (as a percent of the computed tile size) :returns: Optimal tile size according to benchmarked memory usage .. py:function:: get_max_disp_from_opt_tile_size(opt_epipolar_tile_size, max_ram_per_worker, margin=0, used_disparity_range=0) Compute max range possible depending on max ram per worker Return max range usable :param opt_epipolar_tile_size: used tile size :param max_ram_per_worker: amount of RAM allocated per worker :param tile_size_rounding: Optimal tile size will be aligned to multiples of tile_size_rounding :param margin: margin to remove to the computed tile size (as a percent of the computed tile size) :returns: max disp range to use .. 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, 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