欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

python-pcl installation and examples

程序员文章站 2022-03-29 19:39:00
...

Reference github link: https://github.com/strawlab/python-pcl/blob/master/appveyor.yml

1. Installation in Ubuntu16.04

sudo apt install libpcl-dev -y
pip install python-pcl

2. statistical outlier filter: using a recursive function

# -*- coding: utf-8 -*-
# port of
# http://pointclouds.org/documentation/tutorials/statistical_outlier.php
# you need to download
# http://svn.pointclouds.org/data/tutorials/table_scene_lms400.pcd

import pcl

def sta_filter(p_cloud, neg_p_cloud, ponit_num, p_totalnum):

    if ponit_num > int(0.75*p_totalnum):
        print('filtering...')

        fil = p_cloud.make_statistical_outlier_filter()
        fil.set_mean_k(ponit_num)
        fil.set_std_dev_mul_thresh(1.0)
   
        new_p_cloud = fil.filter()
        new_p_num = new_p_cloud.size

        fil.set_negative(True)
        neg_p_cloud = fil.filter()
        sta_filter(new_p_cloud, neg_p_cloud, new_p_num,  p_totalnum)
    
    else:
        pcl.save(p_cloud,
                 "./pcldata/tutorials/test_1_inliers.pcd")

        pcl.save(neg_p_cloud,
                 "./pcldata/tutorials/test_1_outliers.pcd")


if __name__ == "__main__":
    pcdfile = './pcldata/tutorials/test_1.pcd'
    p_cloud = pcl.load(pcdfile)
    ponit_num = p_cloud.size
    p_totalnum =  ponit_num
    sta_filter(p_cloud, p_cloud, ponit_num, p_totalnum)

 

相关标签: 3D reconstruction