zensvi.transform.PointCloudProcessor

class zensvi.transform.PointCloudProcessor(image_folder: str, depth_folder: str, output_coordinate_scale: float = 45, depth_max: float = 255, log_path: str | pathlib.Path = None)

A class for processing images and depth maps to generate point clouds.

This class provides functionality to load image and depth data, convert them into 3D point clouds, and perform various operations on the resulting point clouds. It supports batch processing of multiple images and offers options for scaling and depth normalization.

Parameters:
  • image_folder (Path) – Path to the folder containing color images.

  • depth_folder (Path) – Path to the folder containing depth images.

  • output_coordinate_scale (float) – Scaling factor for the output coordinates.

  • depth_max (float) – Maximum depth value for normalization.

  • logger (Logger) – Optional logger for tracking operations and errors.

convert_to_point_cloud(depth_img, color_img, depth_max)

Converts a single depth and color image pair to a point cloud.

Parameters:
  • depth_img (np.ndarray) – The depth image.

  • color_img (np.ndarray) – The corresponding color image.

  • depth_max (float) – Maximum value for depth normalization.

Returns:

The generated point cloud with color.

Return type:

o3d.geometry.PointCloud

transform_point_cloud(pcd, origin_x, origin_y, angle, box_extent, box_center)

Transforms the point cloud by translating, rotating, and cropping based on given parameters.

Parameters:
  • pcd (o3d.geometry.PointCloud) – The point cloud to transform.

  • origin_x (float) – X coordinate for translation.

  • origin_y (float) – Y coordinate for translation.

  • angle (float) – Rotation angle in radians.

  • box_extent (List[float]) – Extent of the oriented bounding box.

  • box_center (List[float]) – Center of the oriented bounding box.

Returns:

Transformed point cloud.

Return type:

o3d.geometry.PointCloud

save_point_cloud_csv(pcd, output_path)

Saves the point cloud in CSV format.

Parameters:
  • pcd (o3d.geometry.PointCloud) – The point cloud to save.

  • output_path (str) – Path to save the CSV file.

save_point_cloud_numpy(pcd, output_path)

Saves the point cloud as a NumPy array.

Parameters:
  • pcd (o3d.geometry.PointCloud) – The point cloud to save.

  • output_path (str) – Path to save the NumPy array.

process_multiple_images(data, output_dir=None, save_format='pcd')

Generates a point cloud for each entry in the data based on pre-loaded depth and color images.

Parameters:
  • data (DataFrame) – DataFrame containing image ids, coordinates, and headings.

  • output_dir (str) – Path to the output directory to save point clouds.

  • save_format (str) – Format to save point clouds (‘pcd’, ‘ply’, ‘npz’, ‘csv’).

Returns:

List of unprocessed point clouds with color information if output_dir is None.

Return type:

List[o3d.geometry.PointCloud]

visualize_point_cloud(pcd)

Visualizes a point cloud using Plotly.

Parameters:

pcd (o3d.geometry.PointCloud) – The point cloud object to visualize.