Pure Rust implementation of Point Cloud Library (PCL).
This library provides efficient, safe, and ergonomic APIs for point cloud processing, leveraging Rust's ownership system, zero-cost abstractions, and parallel processing capabilities.
- Memory Safety: Leverages Rust's ownership system for safe memory management
- Zero-Copy Operations: Efficient processing through views and references
- Parallel Processing: Built-in support for parallel operations using Rayon
- Generic Point Types: Flexible point type system supporting various point formats
- Comprehensive I/O: Support for multiple point cloud file formats (PCD, PLY, LAS)
use ferrum_cloud::prelude::*;
fn main() -> Result<()> {
// Load a point cloud
let cloud = io::load_pcd("examples/scene.pcd")?;
// Process the cloud
let processed = cloud
.voxel_downsample(0.05)
.remove_outliers(50, 1.0)?;
// Save the result
io::save_ply(&processed, "examples/processed.ply")?;
Ok(())
}use ferrum_cloud::prelude::*;
fn main() -> Result<()> {
// Create a simple XYZ point cloud
let points = vec![
PointXYZ::new(0.0, 0.0, 0.0),
PointXYZ::new(1.0, 0.0, 0.0),
PointXYZ::new(0.0, 1.0, 0.0),
PointXYZ::new(0.0, 0.0, 1.0),
];
let cloud = PointCloud::from_points(points);
// Create a point cloud with RGB colors
let colored_points = vec![
PointXYZRGB::new(0.0, 0.0, 0.0, 255, 0, 0), // Red
PointXYZRGB::new(1.0, 0.0, 0.0, 0, 255, 0), // Green
PointXYZRGB::new(0.0, 1.0, 0.0, 0, 0, 255), // Blue
];
let colored_cloud = PointCloud::from_points(colored_points);
Ok(())
}use ferrum_cloud::prelude::*;
fn main() -> Result<()> {
let cloud = io::load_pcd("examples/scene.pcd")?;
// Voxel downsampling - reduce density while preserving structure
let downsampled = cloud.voxel_downsample(0.05);
// Statistical outlier removal - remove noisy points
let filtered = downsampled.remove_outliers(50, 1.0)?;
// Radius outlier removal - remove isolated points
let clean = filtered.remove_radius_outliers(0.5, 3);
// Pass-through filter - crop along an axis
let cropped = clean.pass_through(Axis::Z, 0.0, 2.0);
Ok(())
}use ferrum_cloud::prelude::*;
fn main() -> Result<()> {
// Load from different formats
let pcd_cloud = io::load_pcd("input.pcd")?;
let ply_cloud = io::load_ply("input.ply")?;
let las_cloud = io::load_las("input.las")?;
// Save to different formats
io::save_pcd(&pcd_cloud, "output.pcd")?;
io::save_ply(&ply_cloud, "output.ply")?;
io::save_las(&las_cloud, "output.las")?;
Ok(())
}use ferrum_cloud::prelude::*;
fn main() -> Result<()> {
// Access point coordinates
let point = PointXYZ::new(1.0, 2.0, 3.0);
let x = point.x();
let y = point.y();
let z = point.z();
let pos = point.position(); // [f32; 3]
// Calculate distances
let p1 = PointXYZ::new(0.0, 0.0, 0.0);
let p2 = PointXYZ::new(3.0, 4.0, 0.0);
let dist = p1.distance_to(&p2); // 5.0
// Work with colored points
let rgb_point = PointXYZRGB::new(1.0, 2.0, 3.0, 255, 128, 64);
let packed_rgb = rgb_point.rgb(); // 0xFF8040
let normalized = rgb_point.rgb_normalized(); // [1.0, 0.502, 0.251]
Ok(())
}use ferrum_cloud::prelude::*;
fn main() -> Result<()> {
let cloud = io::load_pcd("examples/scene.pcd")?;
// Get cloud information
let num_points = cloud.len();
let is_empty = cloud.is_empty();
// Iterate over points
for point in cloud.iter() {
let pos = point.position();
// Process each point...
}
// Parallel iteration for performance
use rayon::prelude::*;
cloud.par_iter().for_each(|point| {
// Parallel processing...
});
Ok(())
}- PointXYZ: Basic 3D point with x, y, z coordinates
- PointXYZRGB: 3D point with RGB color (r, g, b as u8)
- PointXYZRGBNormal: 3D point with RGB color and normal vector
- PCD: Point Cloud Data (PCL format)
- PLY: Polygon File Format (Stanford format)
- LAS: LiDAR point cloud format
MIT