Function segment_plane_ransac

Source
pub fn segment_plane_ransac(
    cloud: &PointCloud<Point3f>,
    max_iters: usize,
    threshold: f32,
) -> Result<(Vector4<f32>, Vec<usize>)>
Expand description

RANSAC plane segmentation with simplified interface

This function provides a simplified interface for RANSAC plane segmentation that returns plane coefficients and inlier indices directly.

§Arguments

  • cloud - Input point cloud
  • max_iters - Maximum number of RANSAC iterations
  • threshold - Maximum distance for a point to be considered an inlier

§Returns

  • Result<(Vector4<f32>, Vec<usize>)> - Plane coefficients and inlier indices

§Example

use threecrate_algorithms::segment_plane_ransac;
use threecrate_core::{PointCloud, Point3f};
use nalgebra::Vector4;
 
fn main() -> Result<(), Box<dyn std::error::Error>> {
    let cloud = PointCloud::from_points(vec![
        Point3f::new(0.0, 0.0, 0.0),
        Point3f::new(1.0, 0.0, 0.0),
        Point3f::new(0.0, 1.0, 0.0),
    ]);
 
    let (coefficients, inliers) = segment_plane_ransac(&cloud, 1000, 0.01)?;
    println!("Plane coefficients: {:?}", coefficients);
    println!("Found {} inliers", inliers.len());
    Ok(())
}