[英]Display text on point cloud vertex in pyrender/open3d
我正在使用SMPL 演示代码来显示一个人的 SMPL-X 网格。 我不需要采用默认的身体关节,而是需要 select 个顶点对应于网格上的其他一些位置,为此我需要找出这些关节的各自索引。 我能想到的最简单的方法是简单地在每个顶点上显示一些带有数字 ID 的文本,看起来会很乱,但放大应该是获得我需要的东西的快速方法。
我上面链接的演示代码使用 3 个独立的库来显示网格:pyrender、matplotlib 和 open3d。 Matplotlib 非常慢并且在显示网格中的所有顶点时变得不可用,但它也是唯一一个显示顶点索引是微不足道的,因为它非常简单:
for idx, j in enumerate(joints):
ax.text(j[0], j[1], j[2], str(idx), None)
这正是我所需要的。 看起来很乱,但放大后可读性更强,除了需要 5 分钟才能找到正确的 position,因为 matplotlib 3D 的可视化效果非常糟糕。
我花了 1 小时试图弄清楚如何使用 pyrender 或 open3d 实现相同的效果,但我对这两者都不熟悉,而且从我能找到的情况来看,没有一种直接的方法来放置这种点云中某些位置的文本。 有没有人知道如何使用这些库中的任何一个来做到这一点? 任何帮助都感激不尽!
我目前正在使用 Open3D,所以我可能会有一些见解。
我建议阅读有关 io 的 Open3D 文档。
您可以使用open3d.io.read_triangle_mesh('path/to/mesh')
轻松加载网格,并使用sceneWidget.add_3d_label([x, y, z], 'label text')
添加 Label。
下面是一个小例子。 如果您需要鼠标事件,则要复杂得多,但是对于简单地显示它来说,这可能会起作用。 请注意,我只使用点云对其进行了测试。
import open3d as o3d
import open3d.visualization.gui as gui
import open3d.visualization.rendering as rendering
if __name__ == "__main__":
gui.Application.instance.initialize()
window = gui.Application.instance.create_window("Mesh-Viewer", 1024, 750)
scene = gui.SceneWidget()
scene.scene = rendering.Open3DScene(window.renderer)
window.add_child(scene)
# mesh = o3d.io.read_triangle_mesh('path/to/data', print_progress=True)
mesh = o3d.io.read_point_cloud('path/to/data', print_progress=True)
scene.scene.add_geometry("mesh_name", mesh, rendering.MaterialRecord())
bounds = mesh.get_axis_aligned_bounding_box()
scene.setup_camera(60, bounds, bounds.get_center())
labels = [[0, 0, 0]]
for coordinate in labels:
scene.add_3d_label(coordinate, "label at origin")
gui.Application.instance.run() # Run until user closes window
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.