Indices and tables
API Reference
- pointcloud_audit(pcd: PointCloud) Dict[str, Any]
Audit point cloud.
This function audits a point cloud and returns a dictionary containing various statistics and properties of the point cloud.
- Parameters:
pcd (o3d.geometry.PointCloud) – Point cloud.
- Returns:
Dictionary of audit results.
- Return type:
Dict[str, Any]
- Example:
>>> import open3d as o3d >>> office_dataset = o3d.data.OfficePointClouds() >>> office_filename = office_dataset.paths[0] >>> pcd = o3d.io.read_point_cloud(office_filename) >>> results = pointcloud_audit(pcd) >>> print(results)
The returned dictionary contains the following keys:
number_pcd_points: Number of points in the point cloud.
has_normals: Boolean indicating if the point cloud has normals.
has_colors: Boolean indicating if the point cloud has colors.
is_empty: Boolean indicating if the point cloud is empty.
max_x: Maximum x-coordinate value (if not empty).
min_x: Minimum x-coordinate value (if not empty).
max_y: Maximum y-coordinate value (if not empty).
min_y: Minimum y-coordinate value (if not empty).
max_z: Maximum z-coordinate value (if not empty).
min_z: Minimum z-coordinate value (if not empty).
all_points_finite: Boolean indicating if all points are finite (if not empty).
all_points_unique: Boolean indicating if all points are unique (if not empty).
- pointcloud_sanitize(pcd: PointCloud) PointCloud
Sanitize point cloud.
This function sanitizes a point cloud by removing non-finite points and duplicate points. If the point cloud has colors, the associated colors of the removed points are also removed.
- Parameters:
pcd (o3d.geometry.PointCloud) – Point cloud.
- Returns:
Sanitized point cloud.
- Return type:
o3d.geometry.PointCloud
- Example:
>>> import open3d as o3d >>> office_dataset = o3d.data.OfficePointClouds() >>> office_filename = office_dataset.paths[0] >>> pcd = o3d.io.read_point_cloud(office_filename) >>> sanitized_pcd = pointcloud_sanitize(pcd) >>> o3d.visualization.draw_geometries([sanitized_pcd])
The function performs the following steps:
Checks if the point cloud is empty.
Removes non-finite points and their associated colors (if any).
Removes duplicate points and their associated colors (if any).
- get_pointcloud_after_subtracting_point_cloud(pcd: PointCloud, subtract: PointCloud, threshold: float = 0.05) PointCloud
Subtracts one point cloud from another. It removes all the points of the first point cloud that are closer than threshold to some point of the second point cloud.
- Parameters:
pcd (o3d.geometry.PointCloud) – Point cloud to subtract from.
subtract (o3d.geometry.PointCloud) – Point cloud to subtract.
threshold (float) – If a point of the first point cloud is closer to some point of the second point cloud than this value, the point is removed.
- Returns:
The result after subtracting the second point cloud from the first point cloud.
- Return type:
o3d.geometry.PointCloud
- Example:
>>> import open3d as o3d >>> import numpy as np >>> np.random.seed(42) >>> mesh_box = o3d.geometry.TriangleMesh.create_box(width=1.0, height=5.0, depth=1.0) >>> pcd_1 = mesh_box.sample_points_uniformly(number_of_points=10000) >>> mesh_box = o3d.geometry.TriangleMesh.create_box(width=1.5, height=4.0, depth=0.5) >>> pcd_2 = mesh_box.sample_points_uniformly(number_of_points=10000) >>> pcd_1.paint_uniform_color([1, 0, 0]) >>> pcd_2.paint_uniform_color([0, 1, 0]) >>> pcd_1_minus_pcd_2 = get_pointcloud_after_subtracting_point_cloud(pcd_1, pcd_2, threshold=0.02) >>> print(pcd_1_minus_pcd_2) PointCloud with 5861 points. >>> o3d.visualization.draw_geometries([pcd_1, pcd_2]) >>> o3d.visualization.draw_geometries([pcd_1_minus_pcd_2]) >>> pcd_2_minus_pcd_1 = get_pointcloud_after_subtracting_point_cloud(pcd_2, pcd_1, threshold=0.02) >>> print(pcd_2_minus_pcd_1) PointCloud with 4717 points. >>> o3d.visualization.draw_geometries([pcd_2_minus_pcd_1])
The function performs the following steps:
Constructs a KDTree from the points of the second point cloud.
Iterates through the points of the first point cloud.
For each point in the first point cloud, checks if it is closer than the threshold to any point in the second point cloud.
If a point is closer than the threshold, it is removed from the first point cloud.
Returns the resulting point cloud after subtraction.