Function ransac_line_par

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

Ransac Line Segmentation in parallel. Returns the line 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, 0.0, f64::from(i))});
}
// generate an outlier
points.push(SimplePoint{position: Vector3::new(9.0, 0.0, 0.0)});
let buffer = points.into_iter().collect::<HashMapBuffer>();
let line_and_indices = ransac_line_par(&buffer, 0.5, 10);
for i in 0..199{
    // inliers are in the plane
    assert!(line_and_indices.1.contains(&(i as usize)));
}
// outlier is not in the plane
assert!(!line_and_indices.1.contains(&200));

§Panics

If the size of the buffer is < 2.