cars.applications.point_cloud_fusion.point_cloud_tools

This module is responsible for the transition between triangulation and rasterization steps

Module Contents

Functions

create_combined_cloud(→ Tuple[pandas.DataFrame, int])

Combine a list of clouds from sparse or dense matching

create_combined_sparse_cloud(→ Tuple[pandas.DataFrame, ...)

Combine a list of clouds (and their colors) into a pandas dataframe

get_epsg(cloud_list, worker_logger)

Extract epsg from cloud list and check if all the same

filter_cloud_with_mask(nb_points, c_cloud, ...)

Delete masked points with terrain tile mask

compute_terrain_msk(dsm_epsg, xmin, xmax, ymin, ymax, ...)

Compute terrain tile msk bounds

create_combined_dense_cloud(→ Tuple[pandas.DataFrame, int])

Combine a list of clouds (and their colors) into a pandas dataframe

create_point_cloud_index(cloud_list)

Create point cloud index from cloud list keys and color inputs

add_color_information(cloud_list, worker_logger, ...)

Add color information for a current cloud_list item

get_color_type(clouds)

Get color type of the tiles and if the same type.

get_number_bands(cloud_list)

Get max number of bands of clouds

filter_cloud(→ Tuple[pandas.DataFrame, Union[None, ...)

Filter all points of the cloud DataFrame

add_cloud_filtering_msk(clouds_list, elt_pos_infos, ...)

Add a uint16 mask labeled 'mask_label' to the clouds in clouds_list.

cars.applications.point_cloud_fusion.point_cloud_tools.create_combined_cloud(cloud_list: List[xr.Dataset] or List[pandas.DataFrame], dsm_epsg: int, xmin: float = None, xmax: float = None, ymin: int = None, ymax: int = None, epipolar_border_margin: int = 0, margin: float = 0, with_coords: bool = False) Tuple[pandas.DataFrame, int]

Combine a list of clouds from sparse or dense matching into a pandas dataframe. The detailed cases for each cloud type are in the derived function create_combined_sparse_cloud and create_combined_dense_cloud.

Parameters
  • dsm_epsg – epsg code for the CRS of the final output raster

  • xmin – xmin of the rasterization grid (if None, the whole clouds are combined)

  • xmax – xmax of the rasterization grid (if None, the whole clouds are combined)

  • ymin – ymin of the rasterization grid (if None, the whole clouds are combined)

  • ymax – ymax of the rasterization grid (if None, the whole clouds are combined)

  • margin – Margin added for each tile, in meter or degree. (default value: 0)

  • epipolar_border_margin – Margin used to invalidate cells too close to epipolar border. (default value: 0)

  • with_coords – Option enabling the adding to the combined cloud of information of each point to retrieve their positions in the original epipolar images

Returns

Tuple formed with the combined clouds and color in a single pandas dataframe and the epsg code

cars.applications.point_cloud_fusion.point_cloud_tools.create_combined_sparse_cloud(cloud_list: List[pandas.DataFrame], dsm_epsg: int, xmin: float = None, xmax: float = None, ymin: int = None, ymax: int = None, epipolar_border_margin: int = 0, margin: float = 0, with_coords: bool = False) Tuple[pandas.DataFrame, int]

Combine a list of clouds (and their colors) into a pandas dataframe structured with the following labels:

  • if no mask data present in cloud_list datasets:

    labels=[cst.POINTS_CLOUD_VALID_DATA, cst.X, cst.Y, cst.Z] The combined cloud has x, y, z columns along with ‘valid data’ one. The valid data is a mask set to True if the data are not on the epipolar image margin (epipolar_border_margin), otherwise it is set to False.

  • if mask data present in cloud_list datasets:

    labels=[cst.POINTS_CLOUD_VALID_DATA, cst.X, cst.Y, cst.Z, cst.POINTS_CLOUD_MSK] The mask values are added to the dataframe.

Parameters
  • dsm_epsg – epsg code for the CRS of the final output raster

  • xmin – xmin of the rasterization grid (if None, the whole clouds are combined)

  • xmax – xmax of the rasterization grid (if None, the whole clouds are combined)

  • ymin – ymin of the rasterization grid (if None, the whole clouds are combined)

  • ymax – ymax of the rasterization grid (if None, the whole clouds are combined)

  • margin – Margin added for each tile, in meter or degree. (default value: 0)

  • epipolar_border_margin – Margin used to invalidate cells too close to epipolar border. (default value: 0)

  • with_coords – Option enabling the adding to the combined cloud of information of each point to retrieve their positions in the original epipolar images

Returns

Tuple formed with the combined clouds and color in a single pandas dataframe and the epsg code

cars.applications.point_cloud_fusion.point_cloud_tools.get_epsg(cloud_list, worker_logger)

Extract epsg from cloud list and check if all the same

Parameters
  • cloud_list – list of the point clouds

  • worker_logger – the worker logger

cars.applications.point_cloud_fusion.point_cloud_tools.filter_cloud_with_mask(nb_points, c_cloud, c_terrain_tile_data_msk)

Delete masked points with terrain tile mask

Parameters
  • nb_points – total number of point cloud (increase at each point cloud)

  • c_cloud – the point cloud

  • c_terrain_tile_data_msk – terrain tile mask

cars.applications.point_cloud_fusion.point_cloud_tools.compute_terrain_msk(dsm_epsg, xmin, xmax, ymin, ymax, margin, epsg, cloud_list_item, full_x, full_y)

Compute terrain tile msk bounds

If the points clouds are not in the same referential as the roi, it is converted using the dsm_epsg

Parameters
  • dsm_epsg – epsg code for the CRS of the final output raster

  • xmin – xmin of the rasterization grid (if None, the whole clouds are combined)

  • xmax – xmax of the rasterization grid (if None, the whole clouds are combined)

  • ymin – ymin of the rasterization grid (if None, the whole clouds are combined)

  • ymax – ymax of the rasterization grid (if None, the whole clouds are combined)

  • margin – Margin added for each tile, in meter or degree. (default value: 0)

  • epsg – epsg code of the input cloud

  • cloud_list_item – the point cloud

  • full_x – cloud_list_item[X]

  • full_y – cloud_list_item[Y]

cars.applications.point_cloud_fusion.point_cloud_tools.create_combined_dense_cloud(cloud_list: List[xarray.Dataset], dsm_epsg: int, xmin: float = None, xmax: float = None, ymin: int = None, ymax: int = None, epipolar_border_margin: int = 0, margin: float = 0, with_coords: bool = False) Tuple[pandas.DataFrame, int]

Combine a list of clouds (and their colors) into a pandas dataframe structured with the following labels:

  • if no colors in input and no mask data present in cloud_list datasets:

    labels=[cst.POINTS_CLOUD_VALID_DATA, cst.X, cst.Y, cst.Z] The combined cloud has x, y, z columns along with ‘valid data’ one. The valid data is a mask set to True if the data are not on the epipolar image margin (epipolar_border_margin), otherwise it is set to False.

  • if no colors in input and mask data present in cloud_list datasets:

    labels=[cst.POINTS_CLOUD_VALID_DATA, cst.X, cst.Y, cst.Z, cst.POINTS_CLOUD_MSK] The mask values are added to the dataframe.

  • if colors are set in input and mask data are present in the cloud_list datasets:

    labels=[cst.POINTS_CLOUD_VALID_DATA, cst.X, cst.Y, cst.Z, cst.POINTS_CLOUD_MSK, cst.POINTS_CLOUD_CLR_KEY_ROOT+”0”, cst.POINTS_CLOUD_CLR_KEY_ROOT+”1”, cst.POINTS_CLOUD_CLR_KEY_ROOT+”2”] Color channels information are added to the dataframe.

  • if colors in input, mask data present in the cloud_list datasets and the with_coords option is activated:

    labels=[cst.POINTS_CLOUD_VALID_DATA, cst.X, cst.Y, cst.Z, cst.POINTS_CLOUD_MSK, cst.POINTS_CLOUD_CLR_KEY_ROOT+”0”, cst.POINTS_CLOUD_CLR_KEY_ROOT+”1”, cst.POINTS_CLOUD_CLR_KEY_ROOT+”2” cst.POINTS_CLOUD_COORD_EPI_GEOM_I, cst.POINTS_CLOUD_COORD_EPI_GEOM_J, cst.POINTS_CLOUD_IDX_IM_EPI] The pixel position of the xyz point in the original epipolar image (coord_epi_geom_i, coord_epi_geom_j) are added to the dataframe along with the index of its original cloud in the cloud_list input.

Parameters
  • dsm_epsg – epsg code for the CRS of the final output raster

  • xmin – xmin of the rasterization grid (if None, the whole clouds are combined)

  • xmax – xmax of the rasterization grid (if None, the whole clouds are combined)

  • ymin – ymin of the rasterization grid (if None, the whole clouds are combined)

  • ymax – ymax of the rasterization grid (if None, the whole clouds are combined)

  • margin – Margin added for each tile, in meter or degree. (default value: 0)

  • epipolar_border_margin – Margin used to invalidate cells too close to epipolar border. (default value: 0)

  • with_coords – Option enabling the adding to the combined cloud of information of each point to retrieve their positions in the original epipolar images

Returns

Tuple formed with the combined clouds and color in a single pandas dataframe and the epsg code

cars.applications.point_cloud_fusion.point_cloud_tools.create_point_cloud_index(cloud_list)

Create point cloud index from cloud list keys and color inputs

cars.applications.point_cloud_fusion.point_cloud_tools.add_color_information(cloud_list, worker_logger, nb_data, nb_band_clr, cloud_list_idx, bbox, c_cloud)

Add color information for a current cloud_list item

Parameters
  • cloud_list (List(Dataset)) – point cloud dataset

  • worker_logger (Logger) – logger

  • nb_data (list[str]) – list of band data

  • nb_band_clr (int) – number of color band

  • cloud_list_idx (int) – index of the current point cloud

  • bbox (list[int]) – bbox of interest

  • c_cloud (NDArray[float64]) – arranged point cloud

cars.applications.point_cloud_fusion.point_cloud_tools.get_color_type(clouds)

Get color type of the tiles and if the same type.

Parameters

cloud_list (xarray Dataset) – list of clouds

Returns

color type of the tiles list

Return type

str

cars.applications.point_cloud_fusion.point_cloud_tools.get_number_bands(cloud_list)

Get max number of bands of clouds

Parameters

cloud_list (xarray Dataset) – list of clouds

Returns

max number of band

Return type

int

cars.applications.point_cloud_fusion.point_cloud_tools.filter_cloud(cloud: pandas.DataFrame, index_elt_to_remove: List[int], filtered_elt_pos: bool = False) Tuple[pandas.DataFrame, Union[None, pandas.DataFrame]]

Filter all points of the cloud DataFrame which index is in the index_elt_to_remove list.

If filtered_elt_pos is set to True, the information of the removed elements positions in their original epipolar images are returned.

To do so the cloud DataFrame has to be build with the ‘with_coords’ option activated.

Parameters
  • cloud – combined cloud as returned by the create_combined_cloud function

  • index_elt_to_remove – indexes of lines to filter in the cloud DataFrame

  • filtered_elt_pos – if filtered_elt_pos is set to True, the removed points positions in their original epipolar images are returned, otherwise it is set to None

Returns

Tuple composed of the filtered cloud DataFrame and the filtered elements epipolar position information (or None for the latter if filtered_elt_pos is set to False or if the cloud Dataframe has not been build with with_coords option)

cars.applications.point_cloud_fusion.point_cloud_tools.add_cloud_filtering_msk(clouds_list: List[xarray.Dataset], elt_pos_infos: pandas.DataFrame, mask_label: str, mask_value: int = 255)

Add a uint16 mask labeled ‘mask_label’ to the clouds in clouds_list. (in-line function)

TODO only used in tests

Parameters
  • clouds_list – Input list of clouds

  • elt_pos_infos – pandas dataframe composed of cst.POINTS_CLOUD_COORD_EPI_GEOM_I, cst.POINTS_CLOUD_COORD_EPI_GEOM_J, cst.POINTS_CLOUD_IDX_IM_EPI columns as computed in the create_combined_cloud function. Those information are used to retrieve the point position in its original epipolar image.

  • mask_label – label to give to the mask in the datasets

  • mask_value – filtered elements value in the mask