Basic usage
segment-lidar v0.1.5
Import the necessary module:
Create an instance of the SamLidar class and specify the path to the checkpoint file ckpt_path when instantiating the class:
Read the point cloud data from a .las/.laz file using the read method of the SamLidar instance. Provide the path to the point cloud file pointcloud.las as an argument:
Apply the Cloth Simulation Filter (CSF) algorithm for ground filtering using the csf method of the SamLidar instance. This method returns the filtered point cloud cloud, the non-ground non_ground and the ground ground indices:
Perform segmentation using the segment method of the SamLidar instance. This method requires the filtered point cloud cloud as input, and you can optionally provide an image path image_path and labels path labels_path to save the segmentation results as an image and labels, respectively. The segment method returns the segmentation labels labels:
Save results to .las/.laz file using the write method of the SamLidar instance:
Now, the entire code should look like this:
The resulted point cloud contains a new scalar field called segment_id. For visualization and further processing, we recommand using CloudCompare.
The following figure shows the results of the segmentation on the sample data:
Last updated