如何在 open3d 点云中显示文本标签?

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

我尝试在点云中用文本标记某些点(障碍物)。目前我有以下点云:

import open3d as o3d
import numpy as np

pcd = o3d.geometry.PointCloud()                                 # make new frame a pointcloud
pcd.points = o3d.utility.Vector3dVector(img)
obstacles = find_cluster(potential_obstacles)

o3d.visualization.draw_geometries([ pcd, obstacles ],
                                    zoom=0.41999999999999962,
                                    front=[ -0.49481467211023333, 0.062416027669252132, -0.86675410570382283 ],
                                    lookat= [ 0.20215540690279493, 0.25826321104010441, 2.5327259417027266 ],
                                    up=[ 0.068492446325020648, 0.99711550943685279, 0.032702379682518497 ],
                                    width=1920,
                                    height=1080)#

函数

find_cluster()
对于进一步理解来说不是必需的。它将障碍物返回为带有标签编号的彩色点云,并将它们的位置
[x, y, z]
作为 numpy 数组返回。

我想使用此信息以文本形式显示障碍物在点云中位置的“编号”。

point cloud with obstacle

我遇到了

open3d.visualization.gui.Label3D
但不知道如何使用它。有人可以帮我吗?

预先感谢并致以最诚挚的问候,AV

我尝试了以下但没有成功:

o3d.visualization.gui.Label3D('sample Text', [0, 0, 0])

如何使用此命令来使用打开的窗口?

point-clouds open3d
1个回答
0
投票

open3d.visualization.draw_geometries

您可以使用

open3d.t.geometry.TriangleMesh.create_text
生成 3D 文本网格并将其放在您需要的位置。

import open3d as o3d
from open3d.t.geometry import TriangleMesh

hello_open3d_mesh: TriangleMesh = o3d.t.geometry.TriangleMesh.create_text("Hello Open3D", depth=0.1).to_legacy()
hello_open3d_mesh.paint_uniform_color((0.4, 0.1, 0.9))

# Mention transformation matrix in column major order
# Scale down since default mesh is quite big
# Location
location = (1, 3, 6)  # The mesh is not centered at origin, so there is already an offset.
# I am adding another location shift as an example.
hello_open3d_mesh.transform([[0.1, 0, 0, location[0]], [0, 0.1, 0, location[1]], [0, 0, 0.1, location[2]],
                             [0, 0, 0, 1]])
origin = o3d.geometry.TriangleMesh.create_coordinate_frame(size=0.3, origin=[0, 0, 0])

o3d.visualization.draw_geometries([origin, hello_open3d_mesh], mesh_show_back_face=True)

open3d.visualization.gui.Application

o3d.visualization.gui.Label3D
open3d.visualization.gui.Application
一起使用。请参阅 https://www.open3d.org/docs/release/python_api/open3d.visualization.gui.html 并在此处查看其示例 - https://www.open3d.org/docs/release/python_example/visualization /index.html.

open3d.visualization.O3DVisualizer

当使用

O3DVisualizer
时,它有
add_3d_label
方法,允许执行相同的操作。请参阅文档

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