Ubuntu20.04环境下python实现PCD文件中点云数据存储类型ascii与binary的格式转换

  • 安装Anaconda

  • 在Anaconda环境下安装安装 PCL 和 pclpy
    安装pclpy

    conda install -c conda-forge -c davidcaron pclpy
    
  • 报错
    1、ImportError: libqhull_p.so.7: cannot open shared object file: No such file or directory
    解决方法:

    conda install qhull==2019.1
    conda install -c conda-forge -c davidcaron pclpy
    

    2、PackagesNotFoundError: The following packages are not available from current channels
    解决方法:

    conda config --append channels conda-forge
    重新执行报错1的命令
    
  • 转换程序
    1、ascii转binary

    import pclpy.pcl
    
    def ascii_binary(pcd_src_path, pcd_dst_path):
        pcl_file = pclpy.pcl.PointCloud.PointXYZI()
        pclpy.pcl.io.loadPCDFile(pcd_src_path, pcl_file)
        pclpy.pcl.io.savePCDFileBinary(pcd_dst_path, pcl_file)
    
    if __name__ == "__main__":
        import sys
        if len(sys.argv) < 3:
            print("Usage: python convert_pcd.py <source_pcd_path> <destination_pcd_path>")
        else:
            source_path = sys.argv[1]
            destination_path = sys.argv[2]
            ascii_binary(source_path, destination_path)
    

    2、binary转ascii

    import pclpy.pcl
    
    def pcl_binary_ascii(pcd_src_path, pcd_dst_path):
        pcl_file = pclpy.pcl.PointCloud.PointXYZI()
        pclpy.pcl.io.loadPCDFile(pcd_src_path, pcl_file)
        pclpy.pcl.io.savePCDFileASCII(pcd_dst_path, pcl_file)
    
    if __name__ == "__main__":
        import sys
        if len(sys.argv) < 3:
            print("Usage: python convert_pcd.py <source_pcd_path> <destination_pcd_path>")
        else:
            source_path = sys.argv[1]
            destination_path = sys.argv[2]
            pcl_binary_ascii(source_path, destination_path)
    
  • 参考链接:https://blog.csdn.net/zhuxingKevin/article/details/129183767、https://blog.csdn.net/weixin_45552562/article/details/109668589

  • 4
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值