簡體   English   中英

在 pyrender/open3d 中的點雲頂點上顯示文本

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM