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] |
|
Transform a 4 layer grid: (N, M, 4) containing |
|
Transform tiling disp min and max to N+1 M+1 array corresponding |
|
Generate grid of positions by splitting [row_min, row_max] x |
|
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 |
|
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 point cloud for each |
|
Get paired regions (terrain/epipolar) as "geodictionnaries": these |
- cars.core.tiling.grid(xmin: float, ymin: float, xmax: float, ymax: float, xsplit: int, ysplit: int) numpy.ndarray [source]
- 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.transform_four_layers_to_two_layers_grid(tiling_grid, terrain=False)[source]
- Transform a 4 layer grid: (N, M, 4) containing
[rowmin, rowmax, colmin, colmax] when epipolar and [xmin, xmax, ymin, ymax] with x = col and y = row into a 2 layer grid: (N+1, M+1, 2) containing x and y defined like : grid[j, i, 0] = min(xmax, xmin + i * xsplit) and grid[j, i, 1] = min(ymax, ymin + j * ysplit)
- Parameters
tiling_grid (np.ndarray) – tiling grid
- Returns
2D grid
- Return type
np.ndarray
- cars.core.tiling.transform_disp_range_grid_to_two_layers(disp_min_grid, disp_max_grid)[source]
- Transform tiling disp min and max to N+1 M+1 array corresponding
to N+1, M+1 , 2 tiling grid
- Parameters
disp_min_grid (np ndarray) – disp min tiling
disp_max_grid (np ndarray) – disp max tiling
- Returns
disp_min_grid, disp_max_grid
- Return type
np ndarray , np ndarray
- cars.core.tiling.generate_tiling_grid(row_min: float, col_min: float, row_max: float, col_max: float, row_split: int, col_split: int) numpy.ndarray [source]
- Generate grid of positions by splitting [row_min, row_max] x
[col_min, col_max] in splits of row_split x col_split size
:param row_min : row_min of the bounding box of the region to split :param col_min : col_min of the bounding box of the region to split :param row_max : row_max of the bounding box of the region to split :param col_max : col_max of the bounding box of the region to split :param row_split: height of splits :param col_split: width of splits
- Returns
The output ndarray grid with nb_row_split splits in first direction and nb_col_split in second direction for 2 dimensions 0:y, 1:x [row, col, :] containing [row_min, row_max, col_min, col_max]
- Return type
numpy array
- cars.core.tiling.split(xmin, ymin, xmax, ymax, xsplit, ysplit)[source]
- 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)[source]
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)[source]
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)[source]
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)[source]
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)[source]
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)[source]
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)[source]
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.filter_simplices_on_the_edges(original_grid_shape: Tuple, tri: scipy.spatial.Delaunay, simplices: numpy.ndarray)[source]
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_tiling_grid, epipolar_tiling_grid, epipolar_grid_min, epipolar_grid_max, epsg)[source]
Transform terrain grid to epipolar region
- cars.core.tiling.region_hash_string(region: Tuple)[source]
This lambda will allow to derive a key to index region in the previous dictionary
- Parameters
region – region to hash
- cars.core.tiling.get_corresponding_tiles_row_col(terrain_tiling_grid: numpy.ndarray, row: int, col: int, list_point_clouds: list, list_epipolar_points_min: list, list_epipolar_points_max: list) Tuple[List, List, List] [source]
This function allows to get required point cloud for each terrain region.
- Parameters
terrain_tiling_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 with associated id 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] [source]
Get paired regions (terrain/epipolar) as “geodictionnaries”: these 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 dictionary and Epipolar dictionary containing respectively Terrain tiles in terrain projection and Epipolar tiles in epipolar projection