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