简体   繁体   English

Open3D o3d.visualization.VisualizerWithEditing() 从拾取点获取坐标而不是从队列获取索引

[英]Open3D o3d.visualization.VisualizerWithEditing() get coordinates from picked point and not index from queue

http://www.open3d.org/docs/release/tutorial/visualization/interactive_visualization.html http://www.open3d.org/docs/release/tutorial/visualization/interactive_visualization.html

def pick_points(pcd):
    print("")
    print(
        "1) Please pick at least three correspondences using [shift + left click]"
    )
    print("   Press [shift + right click] to undo point picking")
    print("2) After picking points, press 'Q' to close the window")
    vis = o3d.visualization.VisualizerWithEditing()
    vis.create_window()
    vis.add_geometry(pcd)
    vis.run()  # user picks points
    vis.destroy_window()
    print("")
    return vis.get_picked_points()

I got this function from Open3D.我从 Open3D 得到了这个 function。 When I use this code, it only displays the coordinates in the terminal but returns only the index.当我使用这段代码时,它只在终端中显示坐标,但只返回索引。

[Open3D INFO] Picked point #1375 (10., -0.45, -0.2) to add in queue. [Open3D INFO] 选择点 #1375 (10., -0.45, -0.2) 添加到队列中。

With this index I do not know how I can get the coordinates.有了这个索引,我不知道如何获得坐标。 Any advice how to get the picked points from a pointcloud?关于如何从点云中获取选取的点有什么建议吗?

As a resolution, I want to get the x, y, z coordinate from a picked point (by clicking) from a pointcloud.作为解决方案,我想从点云中选择的点(通过单击)获取 x、y、z 坐标。

You can use the returned index to extract the picked point from the point cloud:您可以使用返回的索引从点云中提取选取的点:

 picked_points = np.asarray(pcd.points)[vis.get_picked_points()]

This returns a numpy array containing the clicked points.这将返回一个包含点击点的 numpy 数组。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM