- 初始化
volume = o3d.pipelines.integration.ScalableTSDFVolume(
voxel_length=0.001,
sdf_trunc=0.002,
color_type=o3d.pipelines.integration.TSDFVolumeColorType.RGB8)
- 合成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))
- 输出成mesh或者point cloud
pcd = volume.extract_point_cloud()
o3d.io.write_point_cloud(os.path.join(self.input, 'gt.ply'), pcd)
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)
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)