Function ransac_plane_serial

Source
pub fn ransac_plane_serial<'a, T: BorrowedBuffer<'a> + Sync>(
    buffer: &'a T,
    distance_threshold: f64,
    num_of_iterations: usize,
) -> (Plane, Vec<usize>)
Expand description

Ransac Plane Segmentation in serial (for maximum speed use ransac_plane_par). Returns the plane with the highest rating/most inliers and the associated indices of the inliers. Iterates over all points in the buffer. The distance_threshold sets the maximum distance to the plane that a point is counted as an inlier from. With num_of_iterations the number of iterations that the algorithm performs can be chosen.

§Examples

#[repr(C)]
#[derive(PointType, Debug, Copy, Clone, bytemuck::AnyBitPattern, bytemuck::NoUninit)]
struct SimplePoint {
    #[pasture(BUILTIN_POSITION_3D)]
   pub position: Vector3<f64>,
}
let mut points = vec![];
// generate some inliers
for i in 0..200{
    points.push(SimplePoint{position: Vector3::new(0.0, f64::from(i), f64::from(i*i))});
}
// generate an outlier
points.push(SimplePoint{position: Vector3::new(9.0, 0.0, 0.0)});
let buffer = points.into_iter().collect::<HashMapBuffer>();
let plane_and_indices = ransac_plane_serial(&buffer, 0.5, 10);
for i in 0..199{
    // inliers are in the plane
    assert!(plane_and_indices.1.contains(&(i as usize)));
}
// outlier is not in the plane
assert!(!plane_and_indices.1.contains(&200));

§Panics

If the size of the buffer is < 3.