cars.core.preprocessing

Preprocessing contains function used in pipelines

Module Contents

Functions

get_utm_zone_as_epsg_code(lon, lat)

Returns the EPSG code of the UTM zone where the lat, lon point falls in

compute_terrain_bbox(sensor_image_left, ...[, ...])

Compute terrain bounding box of current pair

compute_roi_poly(input_roi_poly, input_roi_epsg, epsg)

Compute roi polygon from input roi

compute_epsg(sensor_image_left, sensor_image_right, ...)

Compute epsg to use

crop_terrain_bounds_with_roi(roi_poly, xmin, ymin, ...)

Crop current terrain bounds with roi

compute_terrain_bounds(list_of_terrain_roi[, ...])

Compute Terrain bounds of merged pairs

get_conversion_factor(bounds, epsg, epsg_cloud)

Conmpute conversion factor

convert_optimal_tile_size_with_epsg(bounds, ...)

Convert optimal_tile_size according to epsg.

compute_epipolar_roi(terrain_roi_poly, ...[, ...])

Compute epipolar roi to use

Attributes

PREPROCESSING_TAG

LEFT_ENVELOPE_TAG

RIGHT_ENVELOPE_TAG

ENVELOPES_INTERSECTION_TAG

ENVELOPES_INTERSECTION_BB_TAG

cars.core.preprocessing.PREPROCESSING_TAG = 'pair_preprocessing'
cars.core.preprocessing.LEFT_ENVELOPE_TAG = 'left_envelope'
cars.core.preprocessing.RIGHT_ENVELOPE_TAG = 'right_envelope'
cars.core.preprocessing.ENVELOPES_INTERSECTION_TAG = 'envelopes_intersection'
cars.core.preprocessing.ENVELOPES_INTERSECTION_BB_TAG = 'envelopes_intersection_bounding_box'
cars.core.preprocessing.get_utm_zone_as_epsg_code(lon, lat)

Returns the EPSG code of the UTM zone where the lat, lon point falls in

Parameters
  • lon (float) – longitude of the point

  • lat (float) – latitude of the point

Returns

The EPSG code corresponding to the UTM zone

Return type

int

cars.core.preprocessing.compute_terrain_bbox(sensor_image_left, sensor_image_right, epipolar_image_left, grid_left, grid_right, epsg, geometry_plugin, disp_min=-10, disp_max=10, resolution=0.5, roi_poly=None, pair_key='PAIR_0', pair_folder=None, orchestrator=None, check_inputs=False)

Compute terrain bounding box of current pair

Parameters
  • srtm_dir (str) – srtm directory

  • default_alt (int) – default altitude

  • geoid (str) – geoid path

  • sensor_image_left (dict) – left image Dict Must contain keys : “image”, “color”, “geomodel”, “no_data”, “mask”. Paths must be absolutes

  • sensor_image_right (dict) – right image Dict Must contain keys : “image”, “color”, “geomodel”, “no_data”, “mask”. Paths must be absolutes

  • grid_left (CarsDataset) –

    left 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”,

  • grid_right (CarsDataset) –

    right 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”,

  • epsg (str) – epsg to use

  • geometry_plugin (AbstractGeometry) – geometry plugin to use

  • disp_min (int) – minimum disparity

  • disp_max (int) – maximum disparity

  • resolution (float) – resolution

  • roi_poly (Polygon) – roi polygon

  • pair_key (str) – pair key id

  • pair_folder (str) – pair folder to save data to

  • orchestrator (Orchestrator) – orchestrator

  • check_inputs (bool) – true if user wants to check inputs

Returns

former post prepare configuration

Return type

dict

cars.core.preprocessing.compute_roi_poly(input_roi_poly, input_roi_epsg, epsg)

Compute roi polygon from input roi

Parameters
  • input_roi_poly (shapely Polygon) – roi polygon

  • input_roi_epsg (str) – epsg of roi

  • epsg (str) – epsg to use

Returns

polygon of roi with right epsg

Return type

Polygon

cars.core.preprocessing.compute_epsg(sensor_image_left, sensor_image_right, grid_left, grid_right, geometry_plugin, disp_min=-10, disp_max=10)

Compute epsg to use

Parameters
  • sensor_image_left (dict) – left image Dict Must contain keys : “image”, “color”, “geomodel”, “no_data”, “mask”. Paths must be absolutes

  • sensor_image_right (dict) – right image Dict Must contain keys : “image”, “color”, “geomodel”, “no_data”, “mask”. Paths must be absolutes

  • grid_left (CarsDataset) –

    left 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”,

  • grid_right (CarsDataset) –

    right 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”,

  • geometry_plugin (AbstractGeometry) – geometry plugin to use

  • srtm_dir (str) – srtm directory

  • default_alt (int) – default altitude

  • disp_min (int) – minimum disparity

  • disp_max (int) – maximum disparity

Returns

epsg

Return type

str

cars.core.preprocessing.crop_terrain_bounds_with_roi(roi_poly, xmin, ymin, xmax, ymax)

Crop current terrain bounds with roi

Parameters
  • roi_poly (Shapely Polygon) – Polygon of ROI

  • xmin (float) – xmin

  • ymin (float) – ymin

  • xmax (float) – xmax

  • ymax (float) – ymax

Returns

new xmin, ymin, xmax, ymax

Return type

(float, float, float, float)

cars.core.preprocessing.compute_terrain_bounds(list_of_terrain_roi, roi_poly=None, resolution=0.5)

Compute Terrain bounds of merged pairs

Parameters
  • list_of_terrain_roi (list) – list of terrain roi list of (terrain bbox, terrain epi_tile_size)

  • roi_poly (Polygon) – terrain roi of given roi

  • resolution (float) – list of terrain roi

Returns

bounds, optimal_terrain_tile_width_average

cars.core.preprocessing.get_conversion_factor(bounds, epsg, epsg_cloud)

Conmpute conversion factor

Parameters
  • bounds (list) – terrain bounds

  • epsg (int) – epsg of bounds

  • epsg_cloud (int) – epsg of the input cloud

Returns

conversion factor

Return type

float

cars.core.preprocessing.convert_optimal_tile_size_with_epsg(bounds, optimal_terrain_tile_width, epsg, epsg_cloud)

Convert optimal_tile_size according to epsg. Only if epsg_cloud is different of the output epsg.

Parameters
  • bounds (list) – terrain bounds

  • optimal_terrain_tile_width (float) – initial optimal_terrain_tile_width

  • epsg (int) – target epsg

  • epsg_cloud (int) – epsg of the input cloud

Returns

converted optimal tile size

Return type

float

cars.core.preprocessing.compute_epipolar_roi(terrain_roi_poly, terrain_roi_epsg, geometry_plugin, sensor_image_left, sensor_image_right, grid_left, grid_right, output_path, disp_min=0, disp_max=0)

Compute epipolar roi to use

Parameters
  • terrain_roi_poly – terrain roi polygon

  • terrain_roi_epsg – terrain roi epsg

  • geometry_plugin – geometry plugin to use

  • epsg – epsg

  • disp_min – minimum disparity

  • disp_max – maximum disparity

Returns

epipolar region to use, with tile_size a sample