cars.applications.dense_matching.dense_matching_tools
This module is responsible for the dense matching algorithms: - thus it creates a disparity map from a pair of images
Module Contents
Functions
|
Create mask of disp values which are in the secondary image roi |
|
Get margins for the dense matching steps |
|
Get masks dictionary from the disparity map in output of pandora. |
|
" |
|
Create the disparity dataset. |
|
" |
|
Compute the mask to use in Pandora. |
|
This function will compute disparity. |
Compute optimal tile size according to estimated memory usage |
|
|
Estimate color image of reference from the disparity map and the secondary |
- cars.applications.dense_matching.dense_matching_tools.create_inside_sec_roi_mask(disp: numpy.ndarray, disp_msk: numpy.ndarray, sec_dataset: xarray.Dataset) numpy.ndarray
Create mask of disp values which are in the secondary image roi (255 if in the roi, otherwise 0)
- Parameters
disp – disparity map
disp_msk – disparity map valid values mask
sec_dataset – secondary image dataset
- Returns
mask of valid pixels that are in the secondary image roi
- cars.applications.dense_matching.dense_matching_tools.get_margins(disp_min, disp_max, corr_cfg)
Get margins for the dense matching steps
- Parameters
disp_min (int) – Minimum disparity
disp_max (int) – Maximum disparity
corr_cfg (dict) – Correlator configuration
- Returns
margins of the matching algorithm used
- cars.applications.dense_matching.dense_matching_tools.get_masks_from_pandora(disp: xarray.Dataset, compute_disparity_masks: bool) Dict[str, numpy.ndarray]
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_tools.add_color(output_dataset: xarray.Dataset, color: numpy.ndarray = None, color_mask: numpy.ndarray = None)
” Add color and color mask to dataset
- Parameters
output_dataset – output dataset
color – color array
color_mask – color mask array
- cars.applications.dense_matching.dense_matching_tools.create_disp_dataset(disp: xarray.Dataset, ref_dataset: xarray.Dataset, sec_dataset: xarray.Dataset = None, check_roi_in_sec: bool = False, compute_disparity_masks: bool = False) xarray.Dataset
Create the disparity dataset.
- Parameters
disp – disparity map (result of pandora)
ref_dataset – reference dataset for the considered disparity map
sec_dataset – secondary dataset for the considered disparity map (needed only if the check_roi_in_sec is set to True)
check_roi_in_sec – option to invalid the values of the disparity which end up outside the secondary image roi
compute_disparity_masks – compute_disparity_masks activation status
- Returns
disparity dataset as used in cars
- cars.applications.dense_matching.dense_matching_tools.add_ambiguity(output_dataset: xarray.Dataset, disp: xarray.Dataset, ref_roi: List[int])
” Add ambiguity to dataset
- Parameters
output_dataset – output dataset
disp – disp xarray
- cars.applications.dense_matching.dense_matching_tools.compute_mask_to_use_in_pandora(dataset: xarray.Dataset, msk_key: str, classes_to_ignore: List[int], out_msk_dtype: numpy.dtype = np.int16) numpy.ndarray
Compute the mask to use in Pandora. Valid pixels will be set to the value of the ‘valid_pixels’ field of the correlation configuration file. No data pixels will be set to the value of the ‘no_data’ field of the correlation configuration file. Nonvalid pixels will be set to a value automatically determined to be different from the ‘valid_pixels’ and the ‘no_data’ fields of the correlation configuration file.
- Parameters
dataset – dataset containing the multi-classes mask from which the mask to used in Pandora will be computed
msk_key – key to use to access the multi-classes mask in the dataset
classes_to_ignore –
out_msk_dtype – numpy dtype of the returned mask
- Returns
the mask to use in Pandora
- cars.applications.dense_matching.dense_matching_tools.compute_disparity(left_dataset, right_dataset, corr_cfg, disp_min=None, disp_max=None, mask1_ignored_by_corr=None, mask2_ignored_by_corr=None, use_sec_disp=True, compute_disparity_masks=False) Dict[str, xarray.Dataset]
This function will compute disparity.
- Parameters
left_dataset (xarray.Dataset) – Dataset containing left image and mask
right_dataset (xarray.Dataset) – Dataset containing right image and mask
corr_cfg (dict) – Correlator configuration
disp_min (int) – Minimum disparity (if None, value is taken from left dataset)
disp_max (int) – Maximum disparity (if None, value is taken from left dataset)
mask1_ignored_by_corr (List[int]) – mask values used to ignore by correlation
mask2_ignored_by_corr (List[int]) – mask values used to ignore by correlation
use_sec_disp (bool) – Boolean activating the use of the secondary disparity map
compute_disparity_masks (Boolean) – Activation of compute_disparity_masks mode
- Returns
Dictionary of disparity dataset. Keys are (if it is computed by Pandora):
’ref’ for the left to right disparity map
’sec’ for the right to left disparity map
- cars.applications.dense_matching.dense_matching_tools.optimal_tile_size_pandora_plugin_libsgm(disp_min: int, disp_max: int, min_tile_size: int, max_tile_size: int, otb_max_ram_hint: int = None, 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.
- 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
otb_max_ram_hint – amount of RAM allocated to OTB (if None, will try to read it from environment variable)
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_tools.estimate_color_from_disparity(disp_ref_to_sec: xarray.Dataset, sec_ds: xarray.Dataset, disp_sec_to_ref_with_color: xarray.Dataset) xarray.Dataset
Estimate color image of reference from the disparity map and the secondary color image.
- Parameters
disp_ref_to_sec – disparity map
sec_ds – secondary image dataset
disp_sec_to_ref_with_color – secondary disparity map dataset with color
- Returns
interpolated reference color image dataset