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 (and their colors) into a pandas dataframe

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[xarray.Dataset], dsm_epsg: int, resolution: float = None, xstart: float = None, ystart: float = None, xsize: int = None, ysize: int = None, on_ground_margin: int = 0, epipolar_border_margin: int = 0, radius: float = 1, 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

  • resolution – Resolution of rasterized cells, in cloud CRS units (if None, the whole clouds are combined)

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

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

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

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

  • on_ground_margin – Margin added to the rasterization grid (default value: 0)

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

  • radius – Radius for hole filling (if None, the whole clouds are combined).

  • 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_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