我使用SMPL演示代码来显示一个人的SMPL网格.我需要选择对应于网格上其他位置的顶点,而不是默认的身体关节,为此,我需要计算出这些关节的相应指标。我能想到的最简单的方法就是在每个顶点上用数字id显示一些文本,看起来很混乱,但是放大应该是一种快速获取我所需要的东西的方法。
我上面链接的演示代码使用了3个单独的库来显示网格:py呈现、matplotlib和open3d。Matplotlib非常慢,在显示网格中的所有顶点时变得不可用,但它也是显示顶点索引非常简单的唯一方法,因为它非常容易:
for idx, j in enumerate(joints):
ax.text(j[0], j[1], j[2], str(idx), None)
并产生这个
这正是我所需要的。看起来很乱,但是放大使它更加可读性更强,除非它需要5分钟才能在手上找到正确的位置,因为matplotlib 3D可视化是多么糟糕。
我花了1个小时试图找出如何使用pyrender或open3d实现相同的目标,但我对两者都不熟悉,而且据我所能发现,没有一种简单的方法可以将这类文本放在点云中的某些位置上。有谁知道如何用这两种语言来做这件事吗?任何帮助都将不胜感激!
发布于 2022-04-22 11:06:11
我目前正在使用Open3D,所以我可能有一些见解。
我建议读一读“Open3D 关于io的文档”。
您可以轻松地使用open3d.io.read_triangle_mesh('path/to/mesh')
加载网格,并使用sceneWidget.add_3d_label([x, y, z], 'label text')
添加标签。
下面是一个小例子。如果您需要鼠标事件,这是相当复杂的,但为了简单地显示它,这可能是可行的。请注意,我只用点云测试过它。
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
https://stackoverflow.com/questions/71959737
复制相似问题