cars.core.tiling
Tiling module: contains functions related to regions and tiles management
Module Contents
Functions
|
Generate grid of positions by splitting [xmin, xmax]x[ymin, ymax] |
|
Split a region defined by [xmin, xmax] x [ymin, ymax] |
|
Crop a region by another one |
|
Pad region according to a margin |
|
Check if a region is empty or inconsistent |
|
Returns union of all regions |
|
Given a region, cut largest_region into tiles of size tile_size |
|
Convert roi as array of [xmin, ymin, xmax, ymax] |
|
Given a roi as xmin, ymin, xmax, ymax, snap values to entire step |
|
Transform terrain region to epipolar region |
|
Filter simplices on the edges which allows to cut triangles out of the |
|
Transform terrain grid to epipolar region |
|
This lambda will allow to derive a key |
|
This function allows to get required points cloud for each |
|
Get paired regions (terrain/epipolar) as "geodictionnaries": theses |
- cars.core.tiling.grid(xmin: float, ymin: float, xmax: float, ymax: float, xsplit: int, ysplit: int) numpy.ndarray
- Generate grid of positions by splitting [xmin, xmax]x[ymin, ymax]
in splits of xsplit x ysplit size
:param xmin : xmin of the bounding box of the region to split :param ymin : ymin of the bounding box of the region to split :param xmax : xmax of the bounding box of the region to split :param ymax : ymax of the bounding box of the region to split :param xsplit: width of splits :param ysplit: height of splits
- Returns
The output ndarray grid with nb_ysplits splits in first direction and nb_xsplits in second direction for 2 dimensions 0:x, 1:y
- Return type
numpy array
- cars.core.tiling.split(xmin, ymin, xmax, ymax, xsplit, ysplit)
- Split a region defined by [xmin, xmax] x [ymin, ymax]
in splits of xsplit x ysplit size
:param xmin : xmin of the bounding box of the region to split :type xmin: float :param ymin : ymin of the bounding box of the region to split :type ymin: float :param xmax : xmax of the bounding box of the region to split :type xmax: float :param ymax : ymax of the bounding box of the region to split :type ymax: float :param xsplit: width of splits :type xsplit: int :param ysplit: height of splits :type ysplit: int
- Returns
A list of splits represented by arrays of 4 elements [xmin, ymin, xmax, ymax]
- Return type
list of 4 float
- cars.core.tiling.crop(region1, region2)
Crop a region by another one
- Parameters
region1 (list of four float) – The region to crop as an array [xmin, ymin, xmax, ymax]
region2 (list of four float) – The region used for cropping as an array [xmin, ymin, xmax, ymax]
- Returns
The cropped regiona as an array [xmin, ymin, xmax, ymax]. If region1 is outside region2, might result in inconsistent region
- Return type
list of four float
- cars.core.tiling.pad(region, margins)
Pad region according to a margin
- Parameters
region (list of four floats) – The region to pad
margins (list of four floats) – Margin to add
- Returns
padded region
- Return type
list of four float
- cars.core.tiling.empty(region)
Check if a region is empty or inconsistent
- Parameters
region (list of four float) – region as an array [xmin, ymin, xmax, ymax]
- Returns
True if the region is considered empty (no pixels inside), False otherwise
- Return type
bool
- cars.core.tiling.union(regions)
Returns union of all regions
- Parameters
regions (list of list of four float) – list of region as an array [xmin, ymin, xmax, ymax]
- Returns
xmin, ymin, xmax, ymax
- Return type
list of 4 float
- cars.core.tiling.list_tiles(region, largest_region, tile_size, margin=1)
Given a region, cut largest_region into tiles of size tile_size and return tiles that intersect region within margin pixels.
- Parameters
region (list of four float) – The region to list intersecting tiles
largest_region (list of four float) – The region to split
tile_size (int) – Width of tiles for splitting (squared tiles)
margin (int) – Also include margin neighboring tiles
- Returns
A list of tiles as dicts containing idx and idy
- Return type
list of dict
- cars.core.tiling.roi_to_start_and_size(region, resolution)
Convert roi as array of [xmin, ymin, xmax, ymax] to xmin, ymin, xsize, ysize given a resolution
Beware that a negative spacing is considered for y axis, and thus returned ystart is in fact ymax
- Parameters
region (list of four float) – The region to convert
resolution (float) – The resolution to use to determine sizes
- Returns
xstart, ystart, xsize, ysize tuple
- Return type
list of two float + two int
- cars.core.tiling.snap_to_grid(xmin, ymin, xmax, ymax, resolution)
Given a roi as xmin, ymin, xmax, ymax, snap values to entire step of resolution
- Parameters
xmin (float) – xmin of the roi
ymin (float) – ymin of the roi
xmax (float) – xmax of the roi
ymax (float) – ymax of the roi
resolution (float) – size of cells for snapping
- Returns
xmin, ymin, xmax, ymax snapped tuple
- Return type
list of four float
- cars.core.tiling.terrain_region_to_epipolar(geometry_loader, region, conf, epsg=4326, disp_min=None, disp_max=None, step=100)
Transform terrain region to epipolar region
- cars.core.tiling.filter_simplices_on_the_edges(original_grid_shape: Tuple, tri: scipy.spatial.Delaunay, simplices: numpy.ndarray)
Filter simplices on the edges which allows to cut triangles out of the concave Delaunay triangulation.
- Parameters
original_grid_shape – shape of the original grid (almost regular) used to create delaunay triangulation
tri – Delaunay triangulation
simplices – Selected simplices to filter: set -1 if selected simplex is on the edges
- cars.core.tiling.terrain_grid_to_epipolar(terrain_grid, epipolar_regions_grid, epipolar_grid_min, epipolar_grid_max, epsg)
Transform terrain grid to epipolar region
- cars.core.tiling.region_hash_string(region: Tuple)
This lambda will allow to derive a key to index region in the previous dictionnary
- Parameters
region – region to hash
- cars.core.tiling.get_corresponding_tiles_row_col(terrain_grid: numpy.ndarray, row: int, col: int, list_points_clouds_left: list, list_points_clouds_right: list, list_epipolar_points_min: list, list_epipolar_points_max: list) Tuple[List, List, List]
This function allows to get required points cloud for each terrain region.
- Parameters
terrain_grid – terrain grid positions
row – row
col – column epipolar input tiles where keys are image pairs index and values are epipolar_points_min, epipolar_points_max, largest_epipolar_region, opt_epipolar_tile_size
- Returns
Terrain regions, Corresponding tiles selected from delayed_point_clouds and Terrain regions “rank” allowing to sorting tiles for dask processing
- cars.core.tiling.get_paired_regions_as_geodict(terrain_regions: List, epipolar_regions: List) Tuple[Dict, Dict]
Get paired regions (terrain/epipolar) as “geodictionnaries”: theses objects can be dumped into geojson files to be visualized.
- Parameters
terrain_regions – terrain region respecting cars tiling
epipolar_regions – corresponding epipolar regions
- Returns
Terrain dictionnary and Epipolar dictionnary containing respectively Terrain tiles in terrain projection and Epipolar tiles in epipolar projection