CSF

基于布料模拟的机载LiDAR滤波方法。 这是文章的代码:

https://github.com/jianboqi/CSF

1. 什么是CSF?

CSF是cloth simulation filter算法的简称,其基本原理就是在倒置的点云上放置一块布料,然后模拟布料与点云的作用,最终布料的形状可以近似地形的走势,可以利用点与布料直接的距离对原始点云进行分类(地面点和非地面点)。
CSF_第1张图片

W. Zhang, J. Qi*, P. Wan, H. Wang, D. Xie, X. Wang, and G. Yan, “An Easy-to-Use Airborne LiDAR Data Filtering Method Based on Cloth Simulation,” Remote Sens., vol. 8, no. 6, p. 501, 2016. (http://www.mdpi.com/2072-4292/8/6/501/htm)

2. Python接口的使用。

CSF本身是用C++开发的,可以保证执行效率。只是在此基础上利用了swig对其添加了一层Python的接口。因此可以通过Python执行CSF滤波。

现在,我们用swig包装了CSF的Python接口。 现在使用起来更简单。 这项新功能可以使CSF更易于嵌入到大型项目中。 例如,它可以与Laspy(https://github.com/laspy/laspy)一起使用。 您要做的只是将点云读取到python 2D列表中,并将其传递给CSF。 以下示例显示了如何将其与laspy一起使用。

las格式:

使用las格式需要先安装laspy这个库(pip install laspy)。

# coding: utf-8
import laspy
import CSF
import numpy as np

inFile = laspy.file.File(r"in.las", mode='r') # read a las file
points = inFile.points
xyz = np.vstack((inFile.x, inFile.y, inFile.z)).transpose() # extract x, y, z and put into a list

csf = CSF.CSF()

# prameter settings
csf.params.bSloopSmooth = False
csf.params.cloth_resolution = 0.5
# more details about parameter: http://ramm.bnu.edu.cn/projects/CSF/download/

csf.setPointCloud(xyz)
ground = CSF.VecInt()  # a list to indicate the index of ground points after calculation
non_ground = CSF.VecInt() # a list to indicate the index of non-ground points after calculation
csf.do_filtering(ground, non_ground) # do actual filtering.

outFile = laspy.file.File(r"ground.las",
                          mode='w', header=inFile.header)
outFile.points = points[ground] # extract ground points, and save it to a las file.
outFile.close() # do not forget this

从txt文件读取数据

如果激光雷达数据存储在txt文件中(每行x y z),则也可以直接将其导入。

import CSF

csf = CSF.CSF()
csf.readPointsFromFile('samp52.txt')

csf.params.bSloopSmooth = False
csf.params.cloth_resolution = 0.5

ground = CSF.VecInt()  # a list to indicate the index of ground points after calculation
non_ground = CSF.VecInt() # a list to indicate the index of non-ground points after calculation
csf.do_filtering(ground, non_ground) # do actual filtering.
csf.savePoints(ground,"ground.txt")

参数说明

虽然CSF有几个参数需要设置,但是大部分情况只用修改一两个即可。

  • cloth_resolutinon: 表示布料网格大小,一般与点云间距相当。默认0.5m。
  • bSlopeSmooth: 是否进行边坡后处理。当有陡变地形是设置为ture。
  • rigidness: 布料硬度。可选值1,2,3. 1表示平坦地形。2表示有缓坡的地形。3表示有较陡的地形(比如山地)。

以上就是python点云滤波库CSF的主要使用步骤。

如何在Python中使用CSF

下载源代码。 在python文件夹下:

python setup.py build
python setup.py install 

CSF_第2张图片

如何在Matlab中使用CSF

在matlab文件夹下的demo_mex.m文件中查看更多详细信息。

如何在C ++中使用CSF

现在,CSF由CMake构建,它生成了一个静态库,该库可被其他c ++程序使用。

linux

要构建库,请运行:

mkdir build #or other name
cd build
cmake ..
make
sudo make install

或者如果您想构建库和演示可执行文件csfdemo

mkdir build #or other name
cd build
cmake -DBUILD_DEMO=ON ..
make
sudo make install

你可能感兴趣的:(3D数据集)