基于open3d将RGBD数据利用tsdf合成点云

  1. 初始化
volume = o3d.pipelines.integration.ScalableTSDFVolume(
     voxel_length=0.001, # 分辨率
     sdf_trunc=0.002,  # 截断SDF
     color_type=o3d.pipelines.integration.TSDFVolumeColorType.RGB8)
  1. 合成rgbd数据并加入到定义的volume
for i in range(self.c2w.shape[0]):
    c2w = self.c2w[i].numpy()
    color = self.color[i].numpy()*255
    depth = self.depth[i].numpy()
    rgbd = o3d.geometry.RGBDImage.create_from_color_and_depth(o3d.geometry.Image(np.asarray(color, order="C", dtype=np.uint8)), o3d.geometry.Image(depth), depth_scale=1, depth_trunc=0.5, convert_rgb_to_intensity=False)
    volume.integrate(rgbd, o3d.camera.PinholeCameraIntrinsic(self.W, self.H, self.fx, self.fy, self.cx, self.cy), np.linalg.inv(c2w)) 
  1. 输出成mesh或者point cloud
# point cloud
pcd = volume.extract_point_cloud()
o3d.io.write_point_cloud(os.path.join(self.input, 'gt.ply'), pcd)
# mesh
mesh = volume.extract_triangle_mesh()
o3d.io.write_triangle_mesh(os.path.join(self.input, 'mesh.ply'), mesh)

附加open3d的基本操作

# 读取
model_paths = glob.glob(os.path.join(self.input, '*.fbx'))[0]
mesh2 = o3d.io.read_triangle_mesh(model_paths)
# 采样
pcd2 = mesh2.sample_points_poisson_disk(10000)
# 缩放
pcd2.scale(0.003/(2*self.scale),center=[0,0,0])
# 旋转
R1 = pcd2.get_rotation_matrix_from_xyz((0, 0, np.pi))
pcd2.rotate(R1)
posted @   阿奘  阅读(67)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
  1. 1 黄昏 手嶌葵
黄昏 - 手嶌葵
00:00 / 00:00
An audio error has occurred.
点击右上角即可分享
微信分享提示