cars.core.geometry

this module contains the abstract geometry class to use in the geometry plugins

Submodules

Package Contents

Classes

AbstractGeometry

AbstractGeometry

Functions

read_geoid_file(→ xarray.Dataset)

Read geoid height from the given path

class cars.core.geometry.AbstractGeometry

AbstractGeometry

available_loaders :Dict
classmethod register_subclass(short_name: str)

Allows to register the subclass with its short name :param short_name: the subclass to be registered :type short_name: string

property conf_schema

Returns the input configuration fields required by the geometry loader as a json checker schema. The available fields are defined in the cars/conf/input_parameters.py file

Returns

the geo configuration schema

abstract static triangulate(cars_conf, mode: str, matches: Union[xarray.Dataset, numpy.ndarray], grid1: str, grid2: str, roi_key: Union[None, str] = None) numpy.ndarray

Performs triangulation from cars disparity or matches dataset

Parameters
  • cars_conf – cars input configuration dictionary

  • mode – triangulation mode (constants.DISP_MODE or constants.MATCHES)

  • matches – cars disparity dataset or matches as numpy array

  • grid1 – path to epipolar grid of img1

  • grid2 – path to epipolar grid of image 2

  • roi_key – dataset roi to use (can be cst.ROI or cst.ROI_WITH_MARGINS)

Returns

the long/lat/height numpy array in output of the triangulation

abstract static check_products_consistency(cars_conf) bool

Test if the product is readable by the geometry loader

Param

cars_conf: cars input configuration dictionary

Returns

True if the products are readable, False otherwise

abstract static generate_epipolar_grids(cars_conf, dem: Union[None, str] = None, geoid: Union[None, str] = None, default_alt: Union[None, float] = None, epipolar_step: int = 30) Tuple[numpy.ndarray, numpy.ndarray, List[float], List[float], List[int], float]

Computes the left and right epipolar grids

Parameters
  • cars_conf – cars input configuration dictionary

  • dem – path to the dem folder

  • geoid – path to the geoid file

  • default_alt – default altitude to use in the missing dem regions

  • epipolar_step – step to use to construct the epipolar grids

Returns

Tuple composed of :

  • the left epipolar grid as a numpy array

  • the right epipolar grid as a numpy array

  • the left grid origin as a list of float

  • the left grid spacing as a list of float

  • the epipolar image size as a list of int (x-axis size is given with the index 0, y-axis size with index 1)

  • the disparity to altitude ratio as a float

static matches_to_sensor_coords(grid1: str, grid2: str, matches: numpy.ndarray, matches_type: str, matches_msk: numpy.ndarray = None, ul_matches_shift: Tuple[int, int] = None) Tuple[numpy.ndarray, numpy.ndarray]

Convert matches (sparse or dense matches) given in epipolar coordinates to sensor coordinates. This function is available for loaders if it requires matches in sensor coordinates to perform the triangulation.

This function returns a tuple composed of the matches left and right sensor coordinates as numpy arrays. For each original image, the sensor coordinates are arranged as follows :

  • if the matches are a vector of matching points: a numpy array of size [number of matches, 2]. The last index indicates the ‘x’ coordinate(last index set to 0) or the ‘y’ coordinate (last index set to 1).

  • if matches is a cars disparity dataset: a numpy array of size [nb_epipolar_line, nb_epipolar_col, 2]. Where [nb_epipolar_line, nb_epipolar_col] is the size of the disparity map. The last index indicates the ‘x’ coordinate (last index set to 0) or the ‘y’ coordinate (last index set to 1).

Parameters
  • grid1 – path to epipolar grid of image 1

  • grid2 – path to epipolar grid of image 2

  • matches – cars disparity dataset or matches as numpy array

  • matches_type – matches type (cst.DISP_MODE or cst.MATCHES)

  • matches_msk – matches mask to provide for cst.DISP_MODE

  • ul_matches_shift – coordinates (x, y) of the upper left corner of the matches map (for cst.DISP_MODE) in the original epipolar geometry (use this if the map have been cropped)

Returns

a tuple of numpy array. The first array corresponds to the left matches in sensor coordinates, the second one is the right matches in sensor coordinates.

static sensor_position_from_grid(grid: str, positions: numpy.ndarray) numpy.ndarray

Interpolate the positions given as inputs using the grid

Parameters
  • grid – path to epipolar grid

  • positions – epipolar positions to interpolate given as a numpy array of size [number of points, 2]. The last index indicates the ‘x’ coordinate (last index set to 0) or the ‘y’ coordinate (last index set to 1).

Returns

sensors positions as a numpy array of size [number of points, 2]. The last index indicates the ‘x’ coordinate (last index set to 0) or the ‘y’ coordinate (last index set to 1).

abstract static direct_loc(cars_conf, product_key: str, x_coord: float, y_coord: float, z_coord: float = None, dem: str = None, geoid: str = None, default_elevation: float = None) numpy.ndarray

For a given image point, compute the latitude, longitude, altitude

Advice: to be sure, use x,y,z inputs only

Parameters
  • cars_conf – cars input configuration dictionary

  • product_key – input_parameters.PRODUCT1_KEY or input_parameters.PRODUCT2_KEY to identify which geometric model shall be taken to perform the method

  • x_coord – X Coordinate in input image sensor

  • y_coord – Y Coordinate in input image sensor

  • z_coord – Z Altitude coordinate to take the image

  • dem – if z not defined, take this DEM directory input

  • geoid – if z and dem not defined, take GEOID directory input

  • default_elevation – if z, dem, geoid not defined, take default elevation

Returns

Latitude, Longitude, Altitude coordinates as a numpy array

image_envelope(conf, product_key: str, shp: str, dem: str = None, default_alt: float = None, geoid: str = None)

Export the image footprint to a shapefile

Parameters
  • conf – cars input configuration dictionary

  • product_key – input_parameters.PRODUCT1_KEY or input_parameters.PRODUCT2_KEY to identify which geometric model shall be taken to perform the method

  • shp – Path to the output shapefile

  • dem – Directory containing DEM tiles

  • default_alt – Default altitude above ellipsoid

  • geoid – path to geoid file

cars.core.geometry.read_geoid_file(geoid_path: str) xarray.Dataset

Read geoid height from the given path Geoid is defined in the static configuration.

Geoid is returned as an xarray.Dataset and height is stored in the hgt variable, which is indexed by lat and lon coordinates. Dataset attributes contain geoid bounds geodetic coordinates and latitude/longitude step spacing.

Returns

the geoid height array in meter.