cars.applications.resampling.bicubic_resampling

this module contains the dense_matching application class.

Module Contents

Classes

BicubicResampling

BicubicResampling

Functions

generate_epipolar_images_wrapper(→ Dict[str, ...)

Compute disparity maps from image objects. This function will be run

get_sensors_bounds(sensor_image_left, sensor_image_right)

Get bounds of sensor images

check_tiles_in_sensor(sensor_image_left, ...)

Check if epipolar tiles will be used.

check_tile_inclusion(left_sensor_bounds, ...)

Check if tile is in sensor image

class cars.applications.resampling.bicubic_resampling.BicubicResampling(conf=None)

Bases: cars.applications.resampling.resampling.Resampling

BicubicResampling

check_conf(conf)

Check configuration

Parameters

conf (dict) – configuration to check

Returns

overloaded configuration

Return type

dict

pre_run(grid_left, tile_width, tile_height)

Pre run some computations : tiling grid

Parameters
  • grid_left (CarsDataset) – left grid

  • optimum_tile_size (int) – optimum tile size

Returns

epipolar_regions_grid, epipolar_regions, opt_epipolar_tile_size, largest_epipolar_region,

run(sensor_image_left, sensor_image_right, grid_left, grid_right, orchestrator=None, pair_folder=None, pair_key='PAIR_0', margins_fun=None, tile_width=None, tile_height=None, add_color=True, epipolar_roi=None)

Run resampling application.

Creates left and right CarsDataset filled with xarray.Dataset, corresponding to sensor images resampled in epipolar geometry.

Parameters
  • sensor_images_left (CarsDataset) – tiled sensor left image Dict Must contain keys : “image”, “color”, “geomodel”, “no_data”, “mask”, “classification”. Paths must be absolutes

  • sensor_images_right (CarsDataset) – tiled sensor right image Dict Must contain keys : “image”, “color”, “geomodel”, “no_data”, “mask”, “classification”. Paths must be absolutes

  • grid_left

    left epipolar grid Grid CarsDataset contains :

    • A single tile stored in [0,0], containing a (N, M, 2) shape

      array in xarray Dataset

    • Attributes containing: “grid_spacing”, “grid_origin”, “epipolar_size_x”, “epipolar_size_y”, “epipolar_origin_x”, “epipolar_origin_y”, epipolar_spacing_x”, “epipolar_spacing”, “disp_to_alt_ratio”, :type grid_left: CarsDataset

  • grid_right (CarsDataset) –

    right epipolar grid. Grid CarsDataset contains :

    • A single tile stored in [0,0], containing a (N, M, 2) shape array in xarray Dataset

    • Attributes containing: “grid_spacing”, “grid_origin”, “epipolar_size_x”, “epipolar_size_y”, “epipolar_origin_x”, “epipolar_origin_y”, epipolar_spacing_x”, “epipolar_spacing”, “disp_to_alt_ratio”,

  • orchestrator – orchestrator used

  • pair_folder (directory to save files to) – folder used for current pair

  • pair_key (str) – pair id

  • margins_fun (fun) – margins function to use

  • optimum_tile_size (int) – optimum tile size to use

  • tile_width (int) – width of tile

  • tile_height (int) – height of tile

  • add_color (bool) – add color image to dataset

  • epipolar_roi (list(int), [row_min, row_max, col_min, col_max]) – Epipolar roi to use if set. Set None tiles outsize roi

Returns

left epipolar image, right epipolar image. Each CarsDataset contains:

  • N x M Delayed tiles. Each tile will be a future xarray Dataset containing:

    • data with keys : “im”, “msk”, “color”, “classif”

    • attrs with keys: “margins” with “disp_min” and “disp_max” “transform”, “crs”, “valid_pixels”, “no_data_mask”,

      ”no_data_img”

  • attributes containing: “largest_epipolar_region”,”opt_epipolar_tile_size”,

    ”disp_min_tiling”, “disp_max_tiling”

Return type

Tuple(CarsDataset, CarsDataset)

cars.applications.resampling.bicubic_resampling.generate_epipolar_images_wrapper(left_overlaps, right_overlaps, window, epipolar_size_x, epipolar_size_y, img1, img2, grid1, grid2, step=None, used_disp_min=None, used_disp_max=None, add_color=True, color1=None, mask1=None, mask2=None, classif1=None, classif2=None, nodata1=0, nodata2=0, saving_info_left=None, saving_info_right=None) Dict[str, Tuple[xarray.Dataset, xarray.Dataset]]

Compute disparity maps from image objects. This function will be run as a delayed task. If user want to correctly save dataset, the user must provide saving_info_left and right. See cars_dataset.fill_dataset.

Parameters
  • left_overlaps (dict) – Overlaps of left image, with row_min, row_max, col_min and col_max keys.

  • right_overlaps (dict) – Overlaps of right image, with row_min, row_max, col_min and col_max keys.

  • window (dict) – Window considered in generation, with row_min, row_max, col_min and col_max keys.

Returns

Left image object, Right image object (if exists)

Returned objects are composed of dataset with :

  • cst.EPI_IMAGE

  • cst.EPI_MSK (if given)

  • cst.EPI_COLOR (for left, if given)

cars.applications.resampling.bicubic_resampling.get_sensors_bounds(sensor_image_left, sensor_image_right)

Get bounds of sensor images Bounds: BoundingBox(left, bottom, right, top)

Parameters
  • sensor_image_left (dict) – left sensor

  • sensor_image_right (dict) – right sensor

Returns

left image bounds, right image bounds

Return type

tuple(list, list)

cars.applications.resampling.bicubic_resampling.check_tiles_in_sensor(sensor_image_left, sensor_image_right, image_tiling, grid_left, grid_right)

Check if epipolar tiles will be used. A tile is not used if is outside sensor bounds

Parameters
  • sensor_image_left (dict) – left sensor

  • sensor_image_right (dict) – right sensor

  • image_tiling (np.array) – epipolar tiling grid

  • grid_left (CarsDataset) – left epipolar grid

  • grid_right (CarsDataset) – right epipolar grid

Returns

left in sensor, right in sensor

Return type

np.array(bool), np.array(bool)

cars.applications.resampling.bicubic_resampling.check_tile_inclusion(left_sensor_bounds, right_sensor_bounds, sensor_pos_left, sensor_pos_right)

Check if tile is in sensor image

Parameters
  • left_sensor_bounds (list) – bounds of left sensor

  • right_sensor_bounds (list) – bounds of right sensor

  • sensor_pos_left (np.array) – left sensor position

  • sensor_pos_right (np.array) – right sensor position

Returns

left tile in sensor image left, right tile in sensor image right

Return type

tuple(bool, bool)