简体   繁体   中英

open3d highlighting point inside point cloud

I have plotted a point cloud using the following function:

def plot_pointcloud(points):
    xyz = points[:, :3]
    pcd = o3d.geometry.PointCloud()
    pcd.points = o3d.utility.Vector3dVector(xyz)
    # pcd.colors = o3d.utility.Vector3dVector(points[:, -1])
    o3d.visualization.draw_geometries([pcd])  # Uncomment this to see the plot

However, I have two questions:

  1. I have 4 points inside this point cloud which I would like to highlight, ie plot those points in a different shape (like a star (*)) as we can do that using matplotlib. Each point has x, y, z coordinates.
  2. I would also like to draw a cuboid inside this point cloud. I know the centroid of the cuboid along with the length, width, and height of the cuboid. I tried to use the http://www.open3d.org/docs/latest/tutorial/Basic/visualization.html geometry_primitives but I couldn't get it to work.

Would appreciate your help.

Thank You.

To highlight your four points, you can create a second point cloud and give this a different colour to the first.

base_point_cloud = o3d.geometry.PointCloud()
picked_point_cloud = o3d.geometry.PointCloud()
base_point_cloud.points = o3d.utility.Vector3dVector(base_3d_pts)
picked_point_cloud.points = o3d.utility.Vector3dVector(picked_3d_pts)
picked_point_cloud.colors = o3d.utility.Vector3dVector(picked_3d_pts)
o3d.visualization.draw_geometries([picked_point_cloud, point_cloud, axis_mesh])

Where base_3d_pts and picked_3d_pts are your 3D points in a numpy array.

An example screenshot is shown below:

Point cloud selected points

You can create a function like this and pass points to it.

def create_geometry_at_points(points):
    geometries = o3d.geometry.TriangleMesh()
    for point in points:
        sphere = o3d.geometry.TriangleMesh.create_sphere(radius=0.005) #create a small sphere to represent point
        sphere.translate(point) #translate this sphere to point
        geometries += sphere
    geometries.paint_uniform_color([1.0, 0.0, 0.0])
    return geometries

Then call:

highlight_pnts = create_geometry_at_points(pcd.points)
o3d.visualization.draw_geometries([pcd, highlight_pnts])

To draw the cube with points :

box = o3d.geometry.TriangleMesh.create_box(width=1.0, height=1.0, depth=1.0, create_uv_map=False, map_texture_to_each_face=False)
box.translate(centre point for box)
o3d.visualization.draw_geometries([pcd, highlight_pnts, box])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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