利用CSF算法实现地面点云的粗分割

参考文章:

点云地面点滤波(Cloth Simulation Filter, CSF)“布料”滤波算法介绍

安装

项目地址: https://github.com/jianboqi/CSF
项目有详细安装说明,对于python版本,先下载整个仓库,然后cd到里面的python目录。


python setup.py build

python setup.py install

实验


def csf_ground_segmentation(data):
    """
    cloth simulation segmentation for point clouds
    :param:data format: np.vstack((x, y,z)..).transpose()  # extract x, y, z and put into a list
    """
    points = data
    # create csf class
    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(points)
    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.
    outpoints = points[ground] # extract ground points
    return outpoints

if __name__="__main__":  
	file = 'xxx.pcd'
	cloud = pcl.load(file) # 取每一帧 file 为指定的pcd点云文件
	filtered_stat = cloud.make_statistical_outlier_filter()
	filtered_stat.set_mean_k(50)
	filtered_stat.set_std_dev_mul_thresh(1.0)
	filtered_point = filtered_stat.filter() # inliers
	filtered_point_np = np.array(filtered_point).astype(np.double)
	ground_p = csf_ground_segmentation(filtered_point_np) # 粗糙地面点
	ground_p_tovisual = pcl.PointCloud(ground_p.astype('float32'))
	# 可视化结果
	visualcolor1 = pcl.pcl_visualization.PointCloudColorHandleringCustom(filtered_point, 0, 255, 0)
	visualcolor2 = pcl.pcl_visualization.PointCloudColorHandleringCustom(ground_p_tovisual, 255, 0, 0)
	vs = pcl.pcl_visualization.PCLVisualizering
	vss1 = pcl.pcl_visualization.PCLVisualizering()  
	vs.AddPointCloud_ColorHandler(vss1, filtered_point, visualcolor1, id=b'cloud', viewport=0)
	vs.AddPointCloud_ColorHandler(vss1, ground_p_tovisual, visualcolor2, id=b'cloud1', viewport=0)
	while not vs.WasStopped(vss1):
	    vs.SpinOnce(vss1)

结果

在这里插入图片描述

可见该算法对于粗糙地面分割还不错。但是对于路沿等边界并没有分割好。

  • 2
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值