API Reference

point_cloud_utils.MORTON_MAX


point_cloud_utils.MORTON_MIN


point_cloud_utils._ray_mesh_intersector.RayMeshIntersector

Class used to find the intersection between rays and a triangle mesh.

__init__(self, mesh_v, mesh_f) special

Create a RayMeshIntersector object which can be used to do ray/mesh queries with a triangle mesh.

Parameters:
  • mesh_v – #v by 3 array of vertex positions (each row is a vertex)

  • mesh_f – #f by 3 Matrix of face (triangle) indices

intersect_rays(self, ray_o, ray_d, ray_near=0.0, ray_far=inf)

Compute intersection between a set of rays and the triangle mesh enclosed in this class

Parameters:
  • ray_o – array of shape (#rays, 3) of ray origins (one per row) or a single array of shape (3,) to use

  • ray_d – array of shape (#rays, 3) of ray directions (one per row)

  • ray_near – an optional floating point value indicating the distance along each ray to start searching (default 0.0)

  • ray_far – an optional floating point value indicating the maximum distance along each ray to search (default inf)

Returns:
  • f_id – an array of shape (#rays,) representing the face id hit by each ray bc : an array of shape (#rays, 3) where each row is the barycentric coordinates within each face of the ray intersection t : the distance along each ray to the intersection


point_cloud_utils._ray_point_cloud_intersector.RaySurfelIntersector

Class used to find the intersection between rays and a point cloud converted to surfels (i.e. a point cloud represented as circles centered at each point and oriented perpendicularly to each normal).

__init__(self, p, n, r=0.1, subdivs=7) special

Construct a RayPointCloudIntersector which can be used to compute the intersection between a set of rays and a point cloud converted to circular patches oriented with the point normals

Parameters:
  • p – #p by 3 array of vertex positions (each row is a vertex)

  • n – #p by 3 Matrix of vertex normals (each row is a vertex)

  • r – Array or Scalar describing the size of each geometry element (Either one radius per vertex, or a global size for the whole point cloud)

  • subdivs – Number of times to subdivide the patch geometry for each point (i.e. # tris per cicle)

intersect_rays(self, ray_o, ray_d, ray_near=0.0, ray_far=inf)

Compute intersection between a set of rays and the point cloud converted to circular patches oriented with the point normals

Parameters:
  • ray_o – array of shape (#rays, 3) of ray origins (one per row) or a single array of shape (3,) to use

  • ray_d – array of shape (#rays, 3) of ray directions (one per row)

  • ray_near – an optional floating point value indicating the distance along each ray to start searching (default 0.0)

  • ray_far – an optional floating point value indicating the maximum distance along each ray to search (default inf)

Returns:
  • t – a (#rays,) shaped array encoding the distance between the ray origin and intersection point for each ray (inf for missed rays) pid : a (#rays,) shaped array of integer indices corresponding to which points were hit (-1 for a ray miss)


point_cloud_utils._mesh_io.TriangleMesh

A lightweight container class representing a triangle mesh with attributes stored at each vertex, wedge, and face, where:

  • A vertex is a 3D position
  • A wedge is a vertex and its two adjacent edges
  • A face is a triangle connecting 3 vertices (Each triangle has 3 vertices and 3 wedges).

The data in encapsulated into vertex data and face data, accessible via TriangleMes.vertex_data and TriangleMesh.face_data respectively:

TriangleMesh.vertex_data:

  • positions: [V, 3]-shaped numpy array of per-vertex positions
  • normals: [V, 3]-shaped numpy array of per-vertex normals (or None)
  • texcoords: [V, 2]-shaped numpy array of per-vertex uv coordinates (or None)
  • tex_ids: [V,]-shaped numpy array of integer indices into TriangleMesh.textures indicating which texture to use at this vertex (or None)
  • colors: [V, 4]-shaped numpy array of per-vertex RBGA colors in [0.0, 1.0] (or None)
  • radius: [V,]-shaped numpy array of per-vertex curvature radii (or None)
  • quality: [V,]-shaped numpy array of per-vertex quality measures (or None)
  • flags: [V,]-shaped numpy array of 32-bit integer flags per vertex (or None)

TriangleMesh.face_data:

  • vertex_ids: [F, 3]-shaped numpy array of integer face indices into TrianglMesh.vertex_data.positions
  • normals: [F, 3]-shaped numpy array of per-face normals (or None)
  • colors: [F, 4]-shaped numpy array of per-face RBGA colors in [0.0, 1.0] (or None)
  • quality: [F,]-shaped numpy array of per-face quality measures (or None)
  • flags: [F,]-shaped numpy array of 32-bit integer flags per face (or None)
  • wedge_colors: [F, 3, 4]-shaped numpy array of per-wedge RBGA colors in [0.0, 1.0] (or None)
  • wedge_normals: [F, 3, 3]-shaped numpy array of per-wedge normals (or None)
  • wedge_texcoords: [F, 3, 2]-shaped numpy array of per-wedge] uv coordinates (or None)
  • wedge_tex_ids: [F, 3]-shaped numpy array of integer indices into TriangleMesh.textures indicating which texture to use at this wedge (or None)
  • textures: A list of paths to texture image files for this mesh
  • normal_maps: A list of paths to texture image files for this mesh

f property readonly

An (m, 3)-shaped integer array containing this mesh's face indices (None if no faces)

fc property readonly

An (m, 4)-shaped array containing this mesh's per-face RBGA colors (None if no face colors)

fn property readonly

An (m, 3)-shaped array containing this mesh's per-face normals (None if no face normals)

v property readonly

An (n, 3)-shaped array containing this mesh's vertex positions

vc property readonly

An (n, 4)-shaped array containing this mesh's per-vertex RGBA (None if no vertex colors)

vn property readonly

An (n, 3)-shaped array containing this mesh's per-vertex normals (None if no vertex normals)

FaceData

A lightweight container class representing per-face information within a TriangleMesh with the following attributes

  • vertex_ids: [F, 3]-shaped numpy array of integer face indices into TrianglMesh.vertex_data.positions
  • normals: [F, 3]-shaped numpy array of per-face normals (or None)
  • colors: [F, 4]-shaped numpy array of per-face RBGA colors in [0.0, 1.0] (or None)
  • quality: [F,]-shaped numpy array of per-face quality measures (or None)
  • flags: [F,]-shaped numpy array of 32-bit integer flags per face (or None)
  • wedge_colors: [F, 3, 4]-shaped numpy array of per-wedge RBGA colors in [0.0, 1.0] (or None)
  • wedge_normals: [F, 3, 3]-shaped numpy array of per-wedge normals (or None)
  • wedge_texcoords: [F, 3, 2]-shaped numpy array of per-wedge] uv coordinates (or None)
  • wedge_tex_ids: [F, 3]-shaped numpy array of integer indices into TriangleMesh.textures indicating which texture to use at this wedge (or None)
  • textures: A list of paths to texture image files for this mesh
  • normal_maps: A list of paths to texture image files for this mesh

VertexData

A lightweight container class representing per-vertex information within a TriangleMesh with the following attributes

  • positions: [V, 3]-shaped numpy array of per-vertex positions
  • normals: [V, 3]-shaped numpy array of per-vertex normals (or None)
  • texcoords: [V, 2]-shaped numpy array of per-vertex uv coordinates (or None)
  • tex_ids: [V,]-shaped numpy array of integer indices into TriangleMesh.textures indicating which texture to use at this vertex (or None)
  • colors: [V, 4]-shaped numpy array of per-vertex RBGA colors in [0.0, 1.0] (or None)
  • radius: [V,]-shaped numpy array of per-vertex curvature radii (or None)
  • quality: [V,]-shaped numpy array of per-vertex quality measures (or None)
  • flags: [V,]-shaped numpy array of 32-bit integer flags per vertex (or None)

load(self, filename, dtype=<class 'numpy.float64'>)

Load a mesh into this class from a file. The type of file is determined by the extension. Point Cloud Utils currently supports PLY, OBJ, STL, OFF, VRML 2.0, X3D, COLLADA, 3DS.

Parameters:
  • filename – Path to the file to be loaded. Must have a valid extension.

  • dtype – Type to save floating point data in (defaults to np.float32)

save(self, filename, dtype=<class 'numpy.float32'>)

Save this mesh to a file. The type of file is determined by the extension. Point Cloud Utils currently supports PLY, OBJ, STL, OFF, VRML 2.0, X3D, COLLADA, 3DS.

Parameters:
  • filename – Path to the file to be saved. Must have a valid extension.

  • dtype – Type to save floating point data in (defaults to np.float32)


point_cloud_utils.chamfer_distance(x, y, return_index=False, p_norm=2, max_points_per_leaf=10)

Compute the chamfer distance between two point clouds x, and y

Parameters:
  • x – A m-sized minibatch of point sets in R^d. i.e. shape [m, n_a, d]

  • y – A m-sized minibatch of point sets in R^d. i.e. shape [m, n_b, d]

  • return_index – If set to True, will return a pair (corrs_x_to_y, corrs_y_to_x) where corrs_x_to_y[i] stores the index into y of the closest point to x[i] (i.e. y[corrs_x_to_y[i]] is the nearest neighbor to x[i] in y). corrs_y_to_x is similar to corrs_x_to_y but with x and y reversed.

  • max_points_per_leaf – The maximum number of points per leaf node in the KD tree used by this function. Default is 10.

  • p_norm – Which norm to use. p_norm can be any real number, inf (for the max norm) -inf (for the min norm), 0 (for sum(x != 0))

Returns:
  • The chamfer distance between x an dy. If return_index is set, then this function returns a tuple (chamfer_dist, corrs_x_to_y, corrs_y_to_x) where corrs_x_to_y and corrs_y_to_x are described above.


point_cloud_utils._pcu_internal.closest_points_on_mesh: None


point_cloud_utils._mesh_primitives.cone_mesh(radius, height, sides=16, bottom=True)

Generate a triangle mesh for a cone centered at the origin and pointing up the y-axis.

Parameters:
  • radius (float) – Radius of the cone's base.

  • height (float) – Height of the cone.

  • sides (int) – Number of segments used to approximate the circular base (default = 16).

  • bottom (bool) – Whether to include faces for the bottom/base of the code (default = True).

Returns:
  • vertices (np.ndarray) – Mesh vertices as an (n, 3)-shaped NumPy array faces (np.ndarray) : Mesh face indices as an (f, 3)-shaped NumPy array


point_cloud_utils._pcu_internal.connected_components: None


point_cloud_utils._mesh_primitives.cube_mesh()

Generate a triangle mesh for a unit cube centered at the origin.

Returns:
  • vertices (np.ndarray) – Mesh vertices as an (n, 3)-shaped NumPy array faces (np.ndarray) : Mesh face indices as an (f, 3)-shaped NumPy array


point_cloud_utils._mesh_primitives.cylinder_mesh(radius, height, sides=16, top=True, bottom=True)

Generate a triangle mesh for a cylinder centered at the origin aligned with the y-axis.

Parameters:
  • radius (float)) – Radius of the cylinder.

  • height (float)) – Height of the cylinder.

  • sides (int)) – Number of sides (segments) for the cylinder (default = 16).

  • top (bool)) – Include top face if True (default = True).

  • bottom (bool)) – Include bottom face if True (default = True).

Returns:
  • vertices (np.ndarray) – List of vertex coordinates (shape = (v, 3)). faces (np.ndarray) : List of faces (triplets of vertex indices with shape = (f, 3)).


point_cloud_utils._pcu_internal.decimate_triangle_mesh: None


point_cloud_utils._pcu_internal.deduplicate_mesh_vertices: None


point_cloud_utils._pcu_internal.deduplicate_point_cloud: None


point_cloud_utils.downsample_point_cloud_on_voxel_grid(voxel_size, points, *args, *, min_bound=None, max_bound=None, min_points_per_voxel=1)

Downsample a point set to conform with a voxel grid by taking the average of points within each voxel.

Parameters:
  • voxel_size – a scalar representing the size of each voxel or a 3 tuple representing the size per axis of each voxel.

  • points – a [#v, 3]-shaped array of 3d points.

  • args – Any additional arguments of shape [#v, ] are treated as attributes and will averaged into each voxel along with the points These will be returns

  • min_bound – a 3 tuple representing the minimum coordinate of the voxel grid or None to use the bounding box of the input point cloud.

  • max_bound – a 3 tuple representing the maximum coordinate of the voxel grid or None to use the bounding box of the input point cloud.

  • min_points_per_voxel – If a voxel contains fewer than this many points, then don't include the points in that voxel in the output.

Returns:
  • A tuple (v, attrib0, attrib1, ....) of downsampled points, and point attributes. Attributes are returned in the same order they are passed in. If no attributes are passed in, then this function simply returns vertices.


point_cloud_utils._pcu_internal.downsample_point_cloud_poisson_disk: None


point_cloud_utils._sinkhorn.earth_movers_distance(p, q, p_norm=2, eps=0.0001, max_iters=100, stop_thresh=0.001)

Compute the (batched) Sinkhorn correspondences between two dirac delta distributions, U, and V. This implementation is numerically stable with float32.

Parameters:
  • p – An (n, d)-shaped array of d-dimensional points

  • b – An (m, d)-shaped array of d-dimensional points

  • p_norm – Which norm to use. Must be one of {non-zero int, inf, -inf, ‘fro’, ‘nuc’} (default is 2),

  • eps – The reciprocal of the sinkhorn regularization parameter (default 1e-4)

  • max_iters – The maximum number of Sinkhorn iterations

  • stop_thresh – Stop if the change in iterates is below this value

Returns:
  • emd – The earth mover's distance between point clouds p and q P : An (n, m)-shaped array of correspondences between point clouds p and q


point_cloud_utils._pcu_internal.estimate_mesh_face_normals: None


point_cloud_utils._pcu_internal.estimate_mesh_vertex_normals: None


point_cloud_utils._pointcloud_normals.estimate_point_cloud_normals_ball(points, ball_radius, view_directions=None, drop_angle_threshold=1.5707963267948966, min_pts_per_ball=3, max_pts_per_ball=-1, weight_function='constant', max_points_per_leaf=10, num_threads=-1)

Estimate normals for a point cloud by locally fitting a plane to all points within a radius of each point (possibly weighted by a radial basis function).

This function can optionally consider directions to the sensor for each point to compute neighborhoods of points which are all facing the same direction, and align the final normal directions.

Parameters:
  • points – (n, 3)-shaped NumPy array of point positions (each row is a point)

  • ball_radius – The radius of each neighborhood used to estimate normals

  • view_directions – (n, 3)-shaped NumPy array or None, representing the unit direction to the sensor for each point. This parameter is used to align the normals and compute neighborhoods of similar facing points.

  • drop_angle_threshold – If view_directions is passed in, drop points whose angle between the normal and view direction exceeds drop_angle_threshold (in radians). Useful for filtering out low quality points.

  • min_pts_per_ball – Discard points whose neighborhood contains fewer than min_pts_per_ball points.

  • max_pts_per_ball – If set to a positive number, then only use max_pts_per_ball points within each neighborhood whose number of points exceeds this value.

  • weight_function – Weighting function for points in a neighborhood. Must be one of 'constant' or 'rbf' where:

  • max_points_per_leaf – Maximum number of points in each leaf node of the KD-tree used for nearest neighbor queries. Tuning this can potentially improve performance on large point clouds.

  • num_threads – Number of threads used to parallelize computation. If set to 0 ir 1, will run in single threaded mode. If set to a positive number t > 1, will use t threads. If set to -1, will use #processors threads for inputs greater than 1 million points.

Returns:
  • p – an (m, 3)-shaped Numpy array of 3d points n : an (m, 3)-shaped Numpy array of unit normals for each point in p

See Also: estimate_pointcloud_normals_ball


point_cloud_utils._pointcloud_normals.estimate_point_cloud_normals_knn(points, num_neighbors, view_directions=None, drop_angle_threshold=1.5707963267948966, max_points_per_leaf=10, num_threads=-1)

Estimate normals for a point cloud by locally fitting a plane to the k nearest neighbors of each point.

This function can optionally consider directions to the sensor for each point to compute neighborhoods of points which are all facing the same direction, and align the final normal directions.

Parameters:
  • points – (n, 3)-shaped NumPy array of point positions (each row is a point)

  • num_neighbors – Integer number of neighbors to use in each neigghborhood.

  • view_directions – (n, 3)-shaped NumPy array or None, representing the unit direction to the sensor for each point. This parameter is used to align the normals and compute neighborhoods of similar facing points.

  • drop_angle_threshold – If view_directions is passed in, drop points whose angle between the normal and view direction exceeds drop_angle_threshold (in radians). Useful for filtering out low quality points.

  • max_points_per_leaf – Maximum number of points in each leaf node of the KD-tree used for nearest neighbor queries. Tuning this can potentially improve performance on large point clouds.

  • num_threads – Number of threads used to parallelize computation. If set to 0 ir 1, will run in single threaded mode. If set to a positive number t > 1, will use t threads. If set to -1, will use #processors threads for inputs greater than 1 million points.

Returns:
  • idx – an (m, 1)-shaped Numpy array of indices into points n : an (m, 3)-shaped Numpy array of unit normals for each point in p

See Also: estimate_pointcloud_normals_ball


point_cloud_utils._voxels.flood_fill_3d(grid, start_coord, fill_value)

Flood fill a 3D grid starting from_start_coord with fill_value. This will return a copy of grid where the region in the input grid which is connected to start_coord and shares the value of start_coord is set to fill_value.

Parameters:
  • grid (np.ndarray) – [w, h, d] array of scalars as input to the flood fill

  • start_coord – (i, j, k) integer coordinate to start the flood fill

  • fill_value – scalar value to flood fill

Returns:
  • _type_ – A flood filled copy of grid where all voxels which are connected to start_coord are set to fill_value


point_cloud_utils.hausdorff_distance(x, y, return_index=False, squared_distances=False, max_points_per_leaf=10)

Compute the Hausdorff distance between x and y

Parameters:
  • x – n by 3 array of representing a set of n points (each row is a point of dimension 3)

  • y – m by 3 array of representing a set of m points (each row is a point of dimension 3)

  • return_index – Optionally return the index pair (i, j) into x and y such that x[i, :] and y[j, :] are the two points with maximum shortest distance.

  • squared_distances – If set to True, then return squared L2 distances. Default is False.

  • max_points_per_leaf – The maximum number of points per leaf node in the KD tree used by this function. Default is 10.

Returns:
  • The largest shortest distance,dbetween each point insourceand the points intarget. Ifreturn_indexis set, then this function returns a tuple (d, i, j) wheredis as described above and(i, j)are such thatsource[i, – ] and target[j, :] are the two points with maximum shortest distance.


point_cloud_utils.interpolate_barycentric_coords(f, fi, bc, attribute)

Interpolate an attribute stored at each vertex of a mesh across the faces of a triangle mesh using barycentric coordinates

Parameters:
  • f – a (#faces, 3)-shaped NumPy array of mesh faces (indexing into some vertex array).

  • fi – a (#attribs,)-shaped NumPy array of indexes into f indicating which face each attribute lies within.

  • bc – a (#attribs, 3)-shaped NumPy array of barycentric coordinates for each attribute

  • attribute – a (#vertices, dim)-shaped NumPy array of attributes at each of the mesh vertices

Returns:
  • A (#attribs, dim)-shaped array of interpolated attributes.


point_cloud_utils._pcu_internal.k_nearest_neighbors: None


point_cloud_utils._pcu_internal.laplacian_smooth_mesh: None


point_cloud_utils._pcu_internal.lloyd_2d: None


point_cloud_utils._pcu_internal.lloyd_3d: None


point_cloud_utils._mesh_io.load_mesh_v(filename, dtype=<class 'float'>)

Load a point cloud consisting only of vertex positions. Point Cloud Utils currently supports PLY, OBJ, STL, OFF, VRML 2.0, X3D, COLLADA, 3DS.

Parameters:
  • filename – Path to the file to be loaded. Must have a valid extension.

  • dtype – The floating point type of loaded data (np.float32 or np.float64)

Returns:
  • v – An (n, 3)-shaped numpy array of coordinates


point_cloud_utils._mesh_io.load_mesh_vc(filename, dtype=<class 'float'>)

Load a point cloud consisting of vertex positions, and vertex colors. Point Cloud Utils currently supports PLY, OBJ, STL, OFF, VRML 2.0, X3D, COLLADA, 3DS.

Parameters:
  • filename – Path to the file to be loaded. Must have a valid extension.

  • dtype – The floating point type of loaded data (np.float32 or np.float64)

Returns:
  • v – An (n, 3)-shaped numpy array of coordinates c : An (n, 3)-shaped or (n, 4)-shaped numpy array of per-vertex RGB or RGBA colors (from 0.0 to 1.0)


point_cloud_utils._mesh_io.load_mesh_vf(filename, dtype=<class 'float'>)

Load a triangle mesh consisting of vertex positions and face indices. Point Cloud Utils currently supports PLY, OBJ, STL, OFF, VRML 2.0, X3D, COLLADA, 3DS.

Parameters:
  • filename – Path to the file to be loaded. Must have a valid extension.

  • dtype – The floating point type of loaded data (np.float32 or np.float64)

Returns:
  • v – An (n, 3)-shaped numpy array of coordinates f : An (m, 3)-shaped integer numpy array of face indices into v


point_cloud_utils._mesh_io.load_mesh_vfc(filename, dtype=<class 'float'>)

Load a triangle mesh consisting of vertex positions, face indices, and vertex colors. Point Cloud Utils currently supports PLY, OBJ, STL, OFF, VRML 2.0, X3D, COLLADA, 3DS.

Parameters:
  • filename – Path to the file to be loaded. Must have a valid extension.

  • dtype – The floating point type of loaded data (np.float32 or np.float64)

Returns:
  • v – An (n, 3)-shaped numpy array of coordinates f : An (m, 3)-shaped integer numpy array of face indices into v c : An (n, 3)-shaped or (n, 4)-shaped numpy array of per-vertex RGB or RGBA colors (from 0.0 to 1.0)


point_cloud_utils._mesh_io.load_mesh_vfn(filename, dtype=<class 'float'>)

Load a triangle mesh consisting of vertex positions, face indices, and vertex normals. Point Cloud Utils currently supports PLY, OBJ, STL, OFF, VRML 2.0, X3D, COLLADA, 3DS.

Parameters:
  • filename – Path to the file to be loaded. Must have a valid extension.

  • dtype – The floating point type of loaded data (np.float32 or np.float64)

Returns:
  • v – An (n, 3)-shaped numpy array of coordinates f : An (m, 3)-shaped integer numpy array of face indices into v n : An (n, 3)-shaped numpy array of per-vertex normals


point_cloud_utils._mesh_io.load_mesh_vfnc(filename, dtype=<class 'float'>)

Load a triangle mesh consisting of vertex positions, face indices, vertex normals, and vertex colors. Point Cloud Utils currently supports PLY, OBJ, STL, OFF, VRML 2.0, X3D, COLLADA, 3DS.

Parameters:
  • filename – Path to the file to be loaded. Must have a valid extension.

  • dtype – The floating point type of loaded data (np.float32 or np.float64)

Returns:
  • v – An (n, 3)-shaped numpy array of coordinates f : An (m, 3)-shaped integer numpy array of face indices into v n : An (n, 3)-shaped numpy array of per-vertex normals c : An (n, 3)-shaped or (n, 4)-shaped numpy array of per-vertex RGB or RGBA colors (from 0.0 to 1.0)


point_cloud_utils._mesh_io.load_mesh_vn(filename, dtype=<class 'float'>)

Load a point cloud consisting of vertex positions, and vertex normals. Point Cloud Utils currently supports PLY, OBJ, STL, OFF, VRML 2.0, X3D, COLLADA, 3DS.

Parameters:
  • filename – Path to the file to be loaded. Must have a valid extension.

  • dtype – The floating point type of loaded data (np.float32 or np.float64)

Returns:
  • v – An (n, 3)-shaped numpy array of coordinates n : An (n, 3)-shaped numpy array of per-vertex normals


point_cloud_utils._mesh_io.load_mesh_vnc(filename, dtype=<class 'float'>)

Load a point cloud consisting of vertex positions, vertex normals, and vertex colors. Point Cloud Utils currently supports PLY, OBJ, STL, OFF, VRML 2.0, X3D, COLLADA, 3DS.

Parameters:
  • filename – Path to the file to be loaded. Must have a valid extension.

  • dtype – The floating point type of loaded data (np.float32 or np.float64)

Returns:
  • v – An (n, 3)-shaped numpy array of coordinates n : An (n, 3)-shaped numpy array of per-vertex normals c : An (n, 3)-shaped or (n, 4)-shaped numpy array of per-vertex RGB or RGBA colors (from 0.0 to 1.0)


point_cloud_utils._mesh_io.load_triangle_mesh(filename, dtype=<class 'numpy.float64'>)

Load a triangle mesh into a TriangleMesh class. Point Cloud Utils currently supports PLY, OBJ, STL, OFF, VRML 2.0, X3D, COLLADA, 3DS.

Parameters:
  • filename – Path to the file to be saved. Must have a valid extension.

  • dtype – The type of floating point number to store the data in (np.float32 or np.float64)

Returns:
  • mesh – A TriangleMesh class containing the loaded mesh


point_cloud_utils._pcu_internal.make_mesh_watertight: None


point_cloud_utils._pcu_internal.marching_cubes_sparse_voxel_grid: None


point_cloud_utils._pcu_internal.mesh_face_areas: None


point_cloud_utils._pcu_internal.morton_add: None


point_cloud_utils._pcu_internal.morton_decode: None


point_cloud_utils._pcu_internal.morton_encode: None


point_cloud_utils._pcu_internal.morton_knn: None


point_cloud_utils._pcu_internal.morton_subtract: None


point_cloud_utils._pcu_internal.one_sided_hausdorff_distance: None


point_cloud_utils._pcu_internal.orient_mesh_faces: None


point_cloud_utils._sinkhorn.pairwise_distances(a, b, p=None)

Compute the (batched) pairwise distance matrix between a and b which both have size [m, n, d] or [n, d]. The result is a tensor of size [m, n, n] (or [n, n]) whose entry [m, i, j] contains the distance_tensor between a[m, i, :] and b[m, j, :].

Parameters:
  • a – A tensor containing m batches of n points of dimension d. i.e. of size (m, n, d)

  • b – A tensor containing m batches of n points of dimension d. i.e. of size (m, n, d)

  • p – Norm to use for the distance_tensor

Returns:
  • M – A (m, n, n)-shaped array containing the pairwise distance_tensor between each pair of inputs in a batch.


point_cloud_utils._pcu_internal.point_cloud_fast_winding_number: None


point_cloud_utils._point_cloud_geometry.pointcloud_sphere_geometry(p, r, num_stacks, num_slices)

Generate sphere geometry for a point cloud (i.e. one sphere per point)

Parameters:
  • p – #p by 3 array of vertex positions (each row is a vertex)

  • r – Array or Scalar describing the radius along each axis (Either one radius per vertex, or a global size for the whole point cloud)

  • num_stacks – Number of latitudal subdivisions

  • num_slices – Number of longitudal subdivisions

Returns:
  • verts – an array of shape (#output_vertices, 3) faces : an array of shape (#output_faces, 3) indexing into verts


point_cloud_utils._point_cloud_geometry.pointcloud_surfel_geometry(p, n, r=0.1, subdivs=7)

Generate geometry for a point cloud encoded as surfels (i.e. circular patches centered at each point and oriented perpendicularly to each normal)

Parameters:
  • p – #p by 3 array of vertex positions (each row is a vertex)

  • n – #p by 3 array of vertex normals (each row is a vertex)

  • r – Array or Scalar describing the size of each geometry element (Either one radius per vertex, or a global size for the whole point cloud)

  • subdivs – Number of times to subdivide the patch geometry for each point (i.e. # tris per cicle)

Returns:
  • verts – an array of shape (#output_vertices, 3) faces : an array of shape (#output_faces, 3) indexing into verts


point_cloud_utils._pcu_internal.ray_mesh_intersection: None


point_cloud_utils._ray_point_cloud_intersector.ray_surfel_intersection(p, n, ray_o, ray_d, r=0.1, subdivs=4, ray_near=0.0, ray_far=inf)

Compute intersection between a set of rays and a point cloud converted to surfels (i.e. circular patches oriented with the point normals)

Parameters:
  • p – #p by 3 array of vertex positions (each row is a vertex)

  • n – #p by 3 Matrix of vertex normals (each row is a vertex)

  • ray_o – array of shape (#rays, 3) of ray origins (one per row) or a single array of shape (3,) to use

  • ray_d – array of shape (#rays, 3) of ray directions (one per row)

  • r – Array or Scalar describing the size of each geometry element (Either one radius per vertex, or a global size for the whole point cloud)

  • subdivs – Number of times to subdivide the patch geometry for each point (i.e. # tris per cicle)

  • ray_near – an optional floating point value indicating the distance along each ray to start searching (default 0.0)

  • ray_far – an optional floating point value indicating the maximum distance along each ray to search (default inf)

Returns:
  • t – a (#rays,) shaped array encoding the distance between the ray origin and intersection point for each ray (inf for missed rays) pid : a (#rays,) shaped array of integer indices corresponding to which points were hit (-1 for a ray miss)


point_cloud_utils._pcu_internal.remove_unreferenced_mesh_vertices: None


point_cloud_utils._pcu_internal.sample_mesh_lloyd: None


point_cloud_utils._pcu_internal.sample_mesh_poisson_disk: None


point_cloud_utils._pcu_internal.sample_mesh_random: None


point_cloud_utils._mesh_io.save_mesh_v(filename, v, dtype=<class 'numpy.float32'>)

Save a point cloud consisting only of vertex positions. Point Cloud Utils currently supports PLY, OBJ, STL, OFF, VRML 2.0, X3D, COLLADA, 3DS.

Parameters:
  • filename – Path to the file to be saved. Must have a valid extension.

  • v – An (n, 3)-shaped numpy array of coordinates

  • dtype – The floating point written to the file (np.float32 or np.float64)


point_cloud_utils._mesh_io.save_mesh_vc(filename, v, c, dtype=<class 'numpy.float32'>)

Save a point cloud consisting of vertex positions and vertex colors. Point Cloud Utils currently supports PLY, OBJ, STL, OFF, VRML 2.0, X3D, COLLADA, 3DS.

Parameters:
  • filename – Path to the file to be saved. Must have a valid extension.

  • v – An (n, 3)-shaped numpy array of coordinates

  • c – An (n, 3)-shaped or (n, 4)-shaped numpy array of per-vertex RGB or RGBA colors (from 0.0 to 1.0)

  • dtype – The floating point written to the file (np.float32 or np.float64)


point_cloud_utils._mesh_io.save_mesh_vf(filename, v, f, dtype=<class 'numpy.float32'>)

Save a triangle mesh consisting of vertex positions and face indices. Point Cloud Utils currently supports PLY, OBJ, STL, OFF, VRML 2.0, X3D, COLLADA, 3DS.

Parameters:
  • filename – Path to the file to be saved. Must have a valid extension.

  • v – An (n, 3)-shaped numpy array of coordinates

  • f – An (m, 3)-shaped integer numpy array of face indices into v

  • dtype – The floating point written to the file (np.float32 or np.float64)


point_cloud_utils._mesh_io.save_mesh_vfc(filename, v, f, c, dtype=<class 'numpy.float32'>)

Save a triangle mesh consisting of vertex positions, face indices, and vertex colors. Point Cloud Utils currently supports PLY, OBJ, STL, OFF, VRML 2.0, X3D, COLLADA, 3DS.

Parameters:
  • filename – Path to the file to be saved. Must have a valid extension.

  • v – An (n, 3)-shaped numpy array of coordinates

  • f – An (m, 3)-shaped integer numpy array of face indices into v

  • c – An (n, 3)-shaped or (n, 4)-shaped numpy array of per-vertex RGB or RGBA colors (from 0.0 to 1.0)

  • dtype – The floating point written to the file (np.float32 or np.float64)


point_cloud_utils._mesh_io.save_mesh_vfn(filename, v, f, n, dtype=<class 'numpy.float32'>)

Save a triangle mesh consisting of vertex positions, face indices, and vertex normals. Point Cloud Utils currently supports PLY, OBJ, STL, OFF, VRML 2.0, X3D, COLLADA, 3DS.

Parameters:
  • filename – Path to the file to be saved. Must have a valid extension.

  • v – An (n, 3)-shaped numpy array of coordinates

  • f – An (m, 3)-shaped integer numpy array of face indices into v

  • n – An (n, 3)-shaped numpy array of per-vertex normals

  • dtype – The floating point written to the file (np.float32 or np.float64)


point_cloud_utils._mesh_io.save_mesh_vfnc(filename, v, f, n, c, dtype=<class 'numpy.float32'>)

Save a triangle mesh consisting of vertex positions, face indices, vertex normals, and vertex colors. Point Cloud Utils currently supports PLY, OBJ, STL, OFF, VRML 2.0, X3D, COLLADA, 3DS.

Parameters:
  • filename – Path to the file to be saved. Must have a valid extension.

  • v – An (n, 3)-shaped numpy array of coordinates

  • f – An (m, 3)-shaped integer numpy array of face indices into v

  • n – An (n, 3)-shaped numpy array of per-vertex normals

  • c – An (n, 3)-shaped or (n, 4)-shaped numpy array of per-vertex RGB or RGBA colors (from 0.0 to 1.0)

  • dtype – The floating point written to the file (np.float32 or np.float64)


point_cloud_utils._mesh_io.save_mesh_vn(filename, v, n, dtype=<class 'numpy.float32'>)

Save a point cloud consisting of vertex positions and vertex normals. Point Cloud Utils currently supports PLY, OBJ, STL, OFF, VRML 2.0, X3D, COLLADA, 3DS.

Parameters:
  • filename – Path to the file to be saved. Must have a valid extension.

  • v – An (n, 3)-shaped numpy array of coordinates

  • n – An (n, 3)-shaped numpy array of per-vertex normals

  • dtype – The floating point written to the file (np.float32 or np.float64)


point_cloud_utils._mesh_io.save_mesh_vnc(filename, v, n, c, dtype=<class 'numpy.float32'>)

Save a point cloud consisting of vertex positions, vertex normals, and vertex colors. Point Cloud Utils currently supports PLY, OBJ, STL, OFF, VRML 2.0, X3D, COLLADA, 3DS.

Parameters:
  • filename – Path to the file to be saved. Must have a valid extension.

  • v – An (n, 3)-shaped numpy array of coordinates

  • n – An (n, 3)-shaped numpy array of per-vertex normals

  • c – An (n, 3)-shaped or (n, 4)-shaped numpy array of per-vertex RGB or RGBA colors (from 0.0 to 1.0)

  • dtype – The floating point written to the file (np.float32 or np.float64)


point_cloud_utils._mesh_io.save_triangle_mesh(filename, v, f=None, vn=None, vt=None, vc=None, vq=None, vr=None, vti=None, vflags=None, fn=None, fc=None, fq=None, fflags=None, wc=None, wn=None, wt=None, wti=None, textures=[], normal_maps=[], dtype=<class 'numpy.float32'>)

Save a triangle mesh to a file with various per-vertex, per-face, and per-wedge attributes. Each argument (except v) is optional and can be None.

Parameters:
  • filename () – Path to the mesh to save. The type of file will be determined from the file extension.

  • v () – [V, 3]-shaped numpy array of per-vertex positions

  • f () – [F, 3]-shaped numpy array of integer face indices into TrianglMesh.vertex_data.positions (or None)

  • vn () – [V, 3]-shaped numpy array of per-vertex normals (or None)

  • vt () – [V, 2]-shaped numpy array of per-vertex uv coordinates (or None)

  • vc () – [V, 4]-shaped numpy array of per-vertex RBGA colors in [0.0, 1.0] (or None)

  • vq () – [V,]-shaped numpy array of per-vertex quality measures (or None)

  • vr () – [V,]-shaped numpy array of per-vertex curvature radii (or None)

  • vti () – [V,]-shaped numpy array of integer indices into TriangleMesh.textures indicating which texture to use at this vertex (or None)

  • vflags () – [V,]-shaped numpy array of 32-bit integer flags per vertex (or None)

  • fn () – [F, 3]-shaped numpy array of per-face normals (or None)

  • fc () – [F, 4]-shaped numpy array of per-face RBGA colors in [0.0, 1.0] (or None)

  • fq () – [F,]-shaped numpy array of per-face quality measures (or None)

  • fflags () – [F,]-shaped numpy array of 32-bit integer flags per face (or None)

  • wc () – [F, 3, 4]-shaped numpy array of per-wedge RBGA colors in [0.0, 1.0] (or None)

  • wn () – [F, 3, 3]-shaped numpy array of per-wedge normals (or None)

  • wt () – [F, 3, 2]-shaped numpy array of per-wedge] uv coordinates (or None)

  • wti () – [F, 3]-shaped numpy array of integer indices into TriangleMesh.textures indicating which

  • textures () – A list of paths to texture image files for this mesh

  • normal_maps – A list of paths to texture image files for this mesh

  • dtype () – The floating point written to the file (np.float32 or np.float64)


point_cloud_utils._pcu_internal.signed_distance_to_mesh: None


point_cloud_utils._sinkhorn.sinkhorn(a, b, M, eps, max_iters=100, stop_thresh=0.001)

Compute the (batched) Sinkhorn correspondences between two dirac delta distributions, U, and V. This implementation is numerically stable with float32.

Parameters:
  • a – A m-sized minibatch of weights for each dirac in the first distribution, U. i.e. shape = (m, n)

  • b – A m-sized minibatch of weights for each dirac in the second distribution, V. i.e. shape = (m, n)

  • M – A minibatch of n-by-n tensors storing the distance between each pair of diracs in U and V. i.e. shape = (m, n, n) and each i.e. M[k, i, j] = ||u[k,_i] - v[k, j]||

  • eps – The reciprocal of the sinkhorn regularization parameter

  • max_iters – The maximum number of Sinkhorn iterations

  • stop_thresh – Stop if the change in iterates is below this value

Returns:
  • P – An (m, n, n)-shaped array of correspondences between distributions U and V


point_cloud_utils._pcu_internal.sparse_voxel_grid_boundary: None


point_cloud_utils._mesh_primitives.sphere_mesh(subdivisions=3)

Generate a triangle mesh approximating a unit sphere centered at the origin by subdividing an isocahedron.

Parameters:
  • subdivisions (int)) – Number of times to subdivide an isocahedron to get the mesh (default = 3).

Returns:
  • vertices (np.ndarray) – Mesh vertices as an (n, 3)-shaped NumPy array faces (np.ndarray) : Mesh face indices as an (f, 3)-shaped NumPy array


point_cloud_utils._pcu_internal.triangle_soup_fast_winding_number: None


point_cloud_utils._pcu_internal.voronoi_centroids_unit_cube: None


point_cloud_utils._point_cloud_geometry.voxel_grid_geometry(ijk, voxel_size=array([1., 1., 1.]), voxel_origin=array([0., 0., 0.]), gap_fraction=0.0)

Generate a triangle mesh of cubes for voxel coordinates ijk. The [0, 0, 0] voxel has its center at voxel_origin and each voxel has voxel_size.

Parameters:
  • ijk (np.ndarray) – [num_voxels, 3] array of integer voxel coordinates

  • voxel_size – Float or triple representing the size of each voxel. Defaults to np.array((1., 1., 1.)).

  • voxel_origin – Center coordinate of the [0, 0, 0] voxel. Defaults to np.array((0., 0., 0.)).

  • gap_fraction – Fraction of a voxel to leave as a gap between voxels (default 0.0)

Returns:
  • v – Numpy array of vertices for the cube mesh f: Numpy array of faces for the cube mesh


point_cloud_utils._voxels.voxelize_triangle_mesh(v, f, voxel_size, voxel_origin)

Return ijk coordinates of voxels which intersect the given mesh. Each voxel is assumed to have size voxel_size (scalar or triple of floats) and the (0, 0, 0) voxel has its bottom-back-left corner at voxel_origin

Parameters:
  • v (np.ndarray) – [num_vertices, 3] array of triangle mesh vertices

  • f (np.ndarray) – [num_faces, 3] array of face indexes into v

  • voxel_size – A float or triple specifying the size of each voxel

  • voxel_origin – A float or triple specifying the the position of the bottom-back-left corner of the (0, 0, 0) voxel

Returns:
  • ijk – [num_vox, 3] array of integer ijk coordinates for each voxel intersecting the mesh