• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

用pythonOpen3d库保存点云,包含强度信息

武飞扬头像
既然如此
帮助1

Open3d保存点云,并包含强度信息

为什么用open3d:

1、pcl库需要python2,而很多库python2不支持

2、open3d是在python3环境下执行的,且支持较多对点云的操作,文档也较多

存在问题:在使用open3d的时候,发现保存的点云没有强度信息

解决方式:将强度信息保存到colors属性上

具体代码过程如下:

注意:将强度信息保存到colors时需要转成0~1的浮点数

  1.  
    import open3d as o3d
  2.  
    import numpy as np
  3.  
     
  4.  
     
  5.  
    path = 'C:\\Users\Administrator\\python_code\\1560.pcd'
  6.  
    a = o3d.io.read_point_cloud(path, format='pcd')
  7.  
     
  8.  
    aa = o3d.geometry.PointCloud()
  9.  
     
  10.  
    b = np.asarray(a.points, dtype = np.float16)
  11.  
    c = np.asarray(a.colors, dtype = np.float16)
  12.  
    c[:,1:3] = c[:,1:3] * 0
  13.  
    c[:,0] = c[:,0]/255.0 ### note !!!
  14.  
     
  15.  
    aa.points = o3d.utility.Vector3dVector(b)
  16.  
    aa.colors = o3d.utility.Vector3dVector(c)
  17.  
     
  18.  
    path_new = 'C:\\Users\Administrator\\python_code\\1560_new.pcd'
  19.  
    o3d.io.write_point_cloud(path_new, aa)
  20.  
     
  21.  
    aaa = o3d.io.read_point_cloud(path_new, format='pcd')
  22.  
    bbb = np.asarray(aaa.points)
  23.  
    ccc = np.asarray(aaa.colors)
  24.  
    ## print the new data
  25.  
    print(bbb[0:5])
  26.  
    print(ccc[0:5])
学新通

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhgfgbea
系列文章
更多 icon
同类精品
更多 icon
继续加载