使用体素创建体素网格 (Open3D)

问题描述 投票:0回答:1

我使用 open3d 对两个点云进行体素化,然后根据每个体素的点数差异对体素进行着色。我通过使用 o3d.geometry.VoxelGrid.create_from_point_cloud() 创建 2 个 VoxelGrid 对象来实现此目的。完成计算后,我最终得到一个体素对象数组,这些对象已分配了颜色。我想用颜色值组装一个新的 VoxelGrid。
在这里,我被困住了,因为我不确定如何做到这一点。

在 o3d 文档中没有任何迹象表明任何函数能够执行此操作。我正在考虑在最终网格中获取我想要的每个体素的中心坐标,使用这些中心坐标和所需的颜色创建一个 o3d.geometry.PointCloud,然后简单地使用 o3d.geometry.VoxelGrid.create_from_point_cloud()。

是否可能存在操作员过载或任何我不知道的情况?我没有丰富的使用 o3d 的经验。

common_voxels = []
vox = self.pc_source.voxel_grid.get_voxels()
cmap = LinearSegmentedColormap.from_list('custom_colormap', [(0, 'green'), (0.5, 'yellow'), (1, 'red')])
norm = plt.Normalize(vmin=delta_min, vmax=delta_max)
sm = ScalarMappable(cmap=cmap, norm=norm)
colors = sm.to_rgba(point_count_delta)


for i, (voxel_idx, source_idx, target_idx, source_point_count, target_point_count) in enumerate(self.common_voxel_point_count_idx_map):
    vox[source_idx].color = colors[i][[0, 1, 2]]
    common_voxels.append(vox[source_idx])
    # vox_center = self.pc_source.voxel_grid.get_center_coordinate
    print(i)

vox_grid = o3d.geometry.VoxelGrid()
for i in range(len(common_voxels)):
    vox_grid += common_voxels[i]

这是我的代码中创建体素对象的部分,我想用它来创建体素网格。

python 3d geometry voxel open3d
1个回答
0
投票

您可以使用

add_voxel
remove_voxel
添加或删除体素。请参阅文档此处此处。然而,这些功能的 Python 绑定最近已添加到 Open3d 中,并且只能通过最新版本使用。通过 this 安装以访问此功能。

添加此功能的 PR 链接 - https://github.com/isl-org/Open3D/pull/6023

© www.soinside.com 2019 - 2024. All rights reserved.