cars.applications.point_cloud_fusion.pc_tif_tools

This module contains functions used during the fusion of point clouds from .tif files.

Module Contents

Functions

create_polygon_from_list_points(list_points)

Create a Shapely polygon from list of points

compute_epsg_from_point_cloud(list_epipolar_points_cloud)

Compute epsg to use from list of tif point clouds

intersect_polygons(poly1, poly2)

Check if two polygons intersect each other

get_min_max_band(image_path_x, image_path_y, ...[, window])

The purpose of this function is only to get the min and max values in

convert_to_polygon(x_y_min_max)

Resample a bounding box and convert it into an shapely polygon

filter_cloud(pd_cloud, bounds)

Remove from the merged cloud all points that are out of the

create_combined_cloud_from_tif(clouds, clouds_id, epsg)

Create combined cloud from tif point clouds

read_band(band_name, band_path, window, ...)

Extract from tif point cloud and put in carsdataset point cloud

generate_point_clouds(list_clouds, orchestrator[, ...])

Generate point cloud cars Datasets from list

read_image_full(band_path[, window, squeeze])

Read image with window

generate_pc_wrapper(cloud, window[, color_type, ...])

Generate point cloud dataset

get_bounds(list_epipolar_points_cloud, epsg[, roi_poly])

Get bounds of clouds

transform_input_pc(list_epipolar_points_cloud, epsg[, ...])

Transform point clouds from inputs into point cloud fusion application

compute_max_nb_point_clouds(...)

Compute the maximum number of point clouds superposing.

compute_average_distance(...)

Compute average distance between points

compute_x_y_min_max_wrapper(items, epsg, window[, ...])

Compute bounds from item and create CarsDict filled with point cloud

get_corresponding_tiles_tif(terrain_tiling_grid, ...)

Get point cloud tiles to use for terrain region

compute_correspondance_single_pc_terrain(epi_pc, ...)

Compute correspondances for each terrain tile, with current point cloud

cars.applications.point_cloud_fusion.pc_tif_tools.create_polygon_from_list_points(list_points)

Create a Shapely polygon from list of points

Parameters

list_points (list) – list of (x, y) coordinates

Returns

Polygon

Return type

shapely Polygon

cars.applications.point_cloud_fusion.pc_tif_tools.compute_epsg_from_point_cloud(list_epipolar_points_cloud)

Compute epsg to use from list of tif point clouds

Parameters

list_epipolar_points_cloud (list(dict)) – list of epipolar point clouds

Returns

epsg

Return type

int

cars.applications.point_cloud_fusion.pc_tif_tools.intersect_polygons(poly1, poly2)

Check if two polygons intersect each other

Parameters
  • poly1 (shapely Polygon) – polygon

  • poly2 (shapely Polygon) – polygon

Returns

True ff intersects

Return type

bool

cars.applications.point_cloud_fusion.pc_tif_tools.get_min_max_band(image_path_x, image_path_y, image_path_z, epsg_in, epsg_utm, window=None)

The purpose of this function is only to get the min and max values in row and col. of these input images, to do so: - Convert input images into a point cloud - Project the points cloud using the global EPSG code - Get the min and max values in row and col

Parameters
  • image_path_x (str) – path to the X image to read

  • image_path_y (str) – path to the Y image to read

  • image_path_z (str) – path to the Z image to read

  • epsg_in (integer) – the EPSG in what the input images coordinates are

  • epsg_utm (integer) – the EPSG code of the UTM referencial in common for all the input clouds

  • window (rasterio window) – specify a region to open inside the image

Returns

an array that contains [xmin, xmax, ymin, ymax] and the code epsg in which the points cloud is projected

cars.applications.point_cloud_fusion.pc_tif_tools.convert_to_polygon(x_y_min_max)

Resample a bounding box and convert it into an shapely polygon

Parameters

x_y_min_max (an array of float [x_min, x_max, y_min, y_max]) – the x/y coordinates of the upper left and lower right points

Returns

an shapely polygon

cars.applications.point_cloud_fusion.pc_tif_tools.filter_cloud(pd_cloud, bounds)

Remove from the merged cloud all points that are out of the terrain tile boundaries.

Parameters
  • pd_cloud (pandas dataframe) – point cloud

  • bounds (array of float [xmin, ymin, xmax, ymax]) – terrain tile bounds

Returns

the epsg out

Return type

int

cars.applications.point_cloud_fusion.pc_tif_tools.create_combined_cloud_from_tif(clouds, clouds_id, epsg, xmin=None, xmax=None, ymin=None, ymax=None, margin=0)

Create combined cloud from tif point clouds

Parameters
  • clouds (list(dict)) – list of clouds

  • clouds_id (list(str)) – list of global identificators associated to clouds

  • epsg (int or str) – epsg to convert point clouds to

  • xmin (float) – min x coordinate

  • xmax (float) – max x coordinate

  • ymin (float) – min y coordinate

  • ymax (float) – max y coordinate

Returns

combined cloud, point cloud epsg

Return type

pandas Dataframe, int

cars.applications.point_cloud_fusion.pc_tif_tools.read_band(band_name, band_path, window, cloud_data_bands, cloud_data_types, cloud_data)

Extract from tif point cloud and put in carsdataset point cloud

Parameters
  • band_name (str) – type of point cloud data

  • band_path (str) – path of the tif point cloud file

  • window (dict) – window to use

  • cloud_data_bands (list) – list of point cloud

  • cloud_data (dict) – point cloud numpy dict

cars.applications.point_cloud_fusion.pc_tif_tools.generate_point_clouds(list_clouds, orchestrator, tile_size=1000)

Generate point cloud cars Datasets from list

Parameters
  • list_clouds (dict) – list of clouds

  • orchestrator (Orchestrator) – orchestrator

  • tile_size (int) – tile size

:return list of point clouds :rtype: list(CarsDataset)

cars.applications.point_cloud_fusion.pc_tif_tools.read_image_full(band_path, window=None, squeeze=False)

Read image with window

Parameters
  • band_path – path to image

  • window – window

  • squeeze – squeeze data if true

:return array

cars.applications.point_cloud_fusion.pc_tif_tools.generate_pc_wrapper(cloud, window, color_type=None, cloud_id=None, list_cloud_ids=None)

Generate point cloud dataset

Parameters
  • cloud – cloud dict

  • window – window

  • color_type – color type

  • cloud_id – cloud id

  • list_cloud_ids – list of global cloud ids

:return cloud :rtype: xr.Dataset

cars.applications.point_cloud_fusion.pc_tif_tools.get_bounds(list_epipolar_points_cloud, epsg, roi_poly=None)

Get bounds of clouds

Parameters
  • list_epipolar_points_cloud (dict) – list of clouds

  • epsg – epsg of wanted roi

  • roi_poly – crop with given roi

:return bounds

cars.applications.point_cloud_fusion.pc_tif_tools.transform_input_pc(list_epipolar_points_cloud, epsg, roi_poly=None, epipolar_tile_size=600, orchestrator=None)

Transform point clouds from inputs into point cloud fusion application format. Create tiles, with x y min max informations.

Parameters
  • list_epipolar_points_cloud (dict) – list of epipolar point clouds

  • epsg (int, str) – epsg

  • roi_poly (Polygon) – roi polygon

  • epipolar_tile_size (int) – size of tile used for tiling the tif files

:return list of point clouds :rtype: list(CarsDataset type dict)

cars.applications.point_cloud_fusion.pc_tif_tools.compute_max_nb_point_clouds(list_epipolar_points_cloud_by_tiles)

Compute the maximum number of point clouds superposing.

Parameters

list_epipolar_points_cloud_by_tiles (list(CarsDataset)) – list of tiled point clouds

Returns

max number of point clouds

Return type

int

cars.applications.point_cloud_fusion.pc_tif_tools.compute_average_distance(list_epipolar_points_cloud_by_tiles)

Compute average distance between points

Parameters

list_epipolar_points_cloud_by_tiles (list(CarsDataset)) – list of tiled point clouds

Returns

average distance between points

Return type

float

cars.applications.point_cloud_fusion.pc_tif_tools.compute_x_y_min_max_wrapper(items, epsg, window, saving_info=None)

Compute bounds from item and create CarsDict filled with point cloud information: file paths, bounds, epsg, window

Parameters
  • items (dict) – point cloud

  • epsg (int) – epsg

  • window (dict) – window to use

  • saving_info (dict) – saving infos

Returns

Tile ready to use

Return type

CarsDict

cars.applications.point_cloud_fusion.pc_tif_tools.get_corresponding_tiles_tif(terrain_tiling_grid, list_epipolar_points_cloud_with_loc, margins=0, orchestrator=None)

Get point cloud tiles to use for terrain region

Parameters
  • terrain_tiling_grid (np.ndarray) – tiling grid

  • row (int) – tiling row

  • col (int) – col

  • list_epipolar_points_cloud_with_loc (list(CarsDataset)) – list of left point clouds

  • margins (float) – margin to use in point clouds

Returns

CarsDataset containing list of point cloud tiles to use to terrain tile

Return type

CarsDataset

cars.applications.point_cloud_fusion.pc_tif_tools.compute_correspondance_single_pc_terrain(epi_pc, epi_pc_id, terrain_tiling_grid, margins=0, saving_info=None)

Compute correspondances for each terrain tile, with current point cloud

Parameters
  • epi_pc (dict) – point cloud

  • epi_pc_id (int) – identificator of the file of the point cloud

  • terrain_tiling_grid (np.ndarray) – tiling grid

  • margins (float) – margin to use in point clouds

Returns

CarsDict containing list of point cloud tiles to use for each terrain tile:

Return type

CarsDict