pub struct PointCloud3D {
pub points: Vec<[f32; 3]>,
pub normals: Option<Vec<[f32; 3]>>,
pub colors: Option<Vec<[u8; 3]>>,
pub intensities: Option<Vec<f32>>,
}Expand description
A 3-D point cloud.
Points are stored as [f32; 3] (x, y, z). Optional per-point attributes
(normals, colours, intensities) are stored as parallel Vecs.
Fields§
§points: Vec<[f32; 3]>[x, y, z] positions.
normals: Option<Vec<[f32; 3]>>Unit surface normals — populated by Self::estimate_normals.
colors: Option<Vec<[u8; 3]>>Per-point RGB colour in [0, 255].
intensities: Option<Vec<f32>>Per-point scalar intensity.
Implementations§
Source§impl PointCloud3D
impl PointCloud3D
Sourcepub fn from_depth_map(depth: &[Vec<f32>], intrinsics: &CameraIntrinsics) -> Self
pub fn from_depth_map(depth: &[Vec<f32>], intrinsics: &CameraIntrinsics) -> Self
Unproject a depth map into a point cloud using pinhole intrinsics.
Pixels with depth ≤ 0 are skipped. The resulting cloud is in the camera frame.
§Arguments
depth–[row][col]depth map in metres.intrinsics– Camera intrinsics for unprojection.
Sourcepub fn bounding_box(&self) -> ([f32; 3], [f32; 3])
pub fn bounding_box(&self) -> ([f32; 3], [f32; 3])
Axis-aligned bounding box: (min_xyz, max_xyz).
Sourcepub fn remove_statistical_outliers(&mut self, k: usize, std_ratio: f64)
pub fn remove_statistical_outliers(&mut self, k: usize, std_ratio: f64)
Remove statistical outliers (SOR filter).
Each point’s mean distance to its k nearest neighbours is computed.
Points whose mean distance exceeds mean + std_ratio * std_dev of the
global distribution are removed.
self is mutated in place. All optional attribute arrays (normals,
colors, intensities) are filtered to match.
Sourcepub fn voxel_downsample(&self, voxel_size: f32) -> Self
pub fn voxel_downsample(&self, voxel_size: f32) -> Self
Downsample the cloud by replacing all points inside each voxel cell with their centroid.
Returns a new cloud. Optional attributes are NOT preserved (they would require averaging, which depends on the attribute semantics).
Sourcepub fn estimate_normals(&mut self, k: usize)
pub fn estimate_normals(&mut self, k: usize)
Estimate per-point surface normals by PCA on the k-nearest neighbour
neighbourhood.
The smallest eigenvector of the 3×3 covariance matrix of the neighbourhood is taken as the normal. Orientation is made consistent by flipping to point “upward” (positive Z component).
self.normals is populated (or replaced) in place.
Sourcepub fn icp_align(
source: &PointCloud3D,
target: &PointCloud3D,
max_iterations: usize,
tolerance: f64,
) -> (PointCloud3D, [[f64; 4]; 4])
pub fn icp_align( source: &PointCloud3D, target: &PointCloud3D, max_iterations: usize, tolerance: f64, ) -> (PointCloud3D, [[f64; 4]; 4])
Align source to target using point-to-point ICP.
Returns the aligned source cloud and the 4×4 cumulative transform.
The algorithm:
- For each source point find the nearest target point.
- Compute the optimal rigid transform via SVD of the cross-covariance.
- Apply the transform and update the cumulative matrix.
- Stop when the mean correspondence distance change is <
toleranceormax_iterationsis reached.
Sourcepub fn k_nearest_neighbors(&self, query: [f32; 3], k: usize) -> Vec<usize>
pub fn k_nearest_neighbors(&self, query: [f32; 3], k: usize) -> Vec<usize>
Return the indices of the k nearest points (excluding self).
Sourcepub fn to_ply_string(&self) -> String
pub fn to_ply_string(&self) -> String
Serialise the cloud to an ASCII PLY string.
Sourcepub fn from_ply_str(s: &str) -> Result<Self, String>
pub fn from_ply_str(s: &str) -> Result<Self, String>
Parse an ASCII PLY string into a PointCloud3D.
Supports property float x/y/z, property float nx/ny/nz, and
property uchar red/green/blue.
Trait Implementations§
Source§impl Clone for PointCloud3D
impl Clone for PointCloud3D
Source§fn clone(&self) -> PointCloud3D
fn clone(&self) -> PointCloud3D
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for PointCloud3D
impl RefUnwindSafe for PointCloud3D
impl Send for PointCloud3D
impl Sync for PointCloud3D
impl Unpin for PointCloud3D
impl UnsafeUnpin for PointCloud3D
impl UnwindSafe for PointCloud3D
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.