davidcaron / pclpy

Python bindings for the Point Cloud Library (PCL)
MIT License
422 stars 59 forks source link

Don segmentation #112

Open akashverma1995 opened 10 months ago

akashverma1995 commented 10 months ago

I tried the difference of normal(DON) for MLS data. I am facing some issue

  1. after loading data in PCLpy, a gap is coming in the input data
  2. The difference of normal is not coming properly

I want to remove vegetation from the data, and for that, I am trying to apply don segmentation. if you have any suggestions please share them with me and how can I check normal computed by pclpy is correct

and I am using below given code

pc_subsampled = pclpy.octree_voxel_downsample(pc, 0.05)
subsampled = pclpy.octree_voxel_downsample(pc_subsampled, 0.4)

normals_large = pcl.PointCloud.PointNormal()
pc_subsampled.compute_normals(radius=4, output_cloud=normals_large, num_threads=8, search_surface=subsampled)
normals_small = pcl.PointCloud.PointNormal()
pc_subsampled.compute_normals(radius=0.10, output_cloud=normals_small, num_threads=8)

don = pcl.features.DifferenceOfNormalsEstimation.PointXYZRGBA_PointNormal_PointNormal()
don.setInputCloud(pc_subsampled)
don.setNormalScaleLarge(normals_large)
don.setNormalScaleSmall(normals_small)
output = pcl.PointCloud.PointNormal(pc_subsampled.xyz)
don.computeFeature(output)
indices = np.argwhere(output.curvature > 0.4)
output2 = pcl.PointCloud.PointNormal(output, pcl.vectors.Int(indices))

clusters = pclpy.extract_clusters(pcl.PointCloud.PointXYZ(output2.xyz), 0.1, 50, 100000)
assert len(clusters) in range(30, 35)  # there is some randomness to the results

`