Search code examples
c++point-cloud-libraryroboticslidarransac

How to extract points that belong to a vertical plane from a point cloud using PCL?


I want to write a program that takes a point cloud data and extract the set of points that belong to a vertical plane. The process mustn’t take more than 100 milliseconds. What is the best way to do this?

I tried using RANSAC filter but, it's slow and also the result is not good.

 pcl::SACSegmentation<pcl::PointXYZ> seg;
    seg.setOptimizeCoefficients(true);
    seg.setModelType(pcl::SACMODEL_PLANE);
    seg.setMethodType(pcl::SAC_RANSAC);
    seg.setMaxIterations(1000);
    seg.setDistanceThreshold(0.01);

Solution

  • First of all, I would recommend to use the latest PCL release (or even the master branch), compiled from source. Compared to PCL 1.9.1, this includes several speed improvements in the sample consensus module. Additionally, by compiling from source, you make sure that you can use everything your computer is capable of (e.g. SIMD instructions). With the latest PCL release (or master branch) you can also use the parallel RANSAC implementation by calling seg.setNumberOfThreads(0). If this is still too slow, you can try to downsample the cloud before passing it to SACSegmentation, e.g. with https://pointclouds.org/documentation/classpcl_1_1_random_sample.html

    If you only want vertical planes (that is, planes that are parallel to a specified axis), you should use SACMODEL_PARALLEL_PLANE instead of SACMODEL_PLANE and call https://pointclouds.org/documentation/classpcl_1_1_s_a_c_segmentation.html#a23abc3e522ccb2b2846a6c9b0cf7b7d3 and https://pointclouds.org/documentation/classpcl_1_1_s_a_c_segmentation.html#a7a2dc31039a1717f83ca281f6970eb18