8

I have generated multiple point clouds using a RGB+depth video, and would like to visualize the multiple point clouds as a video or animation.

Currently I am using Python, part of my code is as follows:

for i in range(1,10)
       pcd = Track.create_pcd(i)
       o3d.visualization.draw_geometries([pcd])
       pcd_list.append(pcd)

When I use draw_geometries or draw_geometries_with_animation_callback, it seems they could not display a list of point clouds:

o3d.visualization.draw_geometries([pcd_list])

or

def rotate_view(vis):
    ctr = vis.get_view_control()
    ctr.rotate(10.0, 0.0)
    return False
    
o3d.visualization.draw_geometries_with_animation_callback([pcd_list],rotate_view)

It gave the following error:

TypeError: draw_geometries(): incompatible function arguments. The following argument types are supported:

  1. (geometry_list: List[open3d.open3d_pybind.geometry.Geometry], window_name: str = ‘Open3D’, width: int = 1920, height: int = 1080, left: int = 50, top: int = 50, point_show_normal: bool = False, mesh_show_wireframe: bool = False, mesh_show_back_face: bool = False) -> None

Is there any example of how to export list of point cloud into a video, like setting a viewer, and displaying each point cloud with a waitkey of 0.5 seconds, and then save as a video file (.mp4/.avi)? And also to get and then set a fixed viewpoint of the point clouds in the video?

Thank you very much!

Ryan
  • 279
  • 1
  • 4
  • 12

1 Answers1

4

You can use Open3D Non-blocking visualization.

It'll be like this

vis = o3d.visualization.Visualizer()
vis.create_window()

# geometry is the point cloud used in your animaiton
geometry = o3d.geometry.PointCloud()
vis.add_geometry(geometry)

for i in range(icp_iteration):
    # now modify the points of your geometry
    # you can use whatever method suits you best, this is just an example
    geometry.points = pcd_list[i].points
    vis.update_geometry(geometry)
    vis.poll_events()
    vis.update_renderer()
Farid Alijani
  • 839
  • 1
  • 7
  • 25
Jing Zhao
  • 2,420
  • 18
  • 21
  • Yess, I was trying these days and have a similar approach. But can you set the view point for the visualizer from json file? My current problem with visualizer is that it could not load the viewpoint from .json file. I could sucessfully save the viewpoint of the point cloud (as a orientation for good visualization) as a .json format (using "Printscreen" button). But when I use `vis.get_render_option().load_from_json("ScreenCamera_2020-07-16-20-57-15.json")` it outputs: `[Open3D WARNING] ViewTrajectory read JSON failed: unsupported json format.` – Ryan Jul 21 '20 at 20:57
  • My quick test with the json file did not success. Currently I don't have too much time to play with this. However IMHO, camera view point setting can be circumvented by inverse transposing the point cloud. It's a little bit of unstylish, but it seems current Open3D release still contains a lot of bugs (I cannot even succeeds in finishing some of the official examples :) – Jing Zhao Jul 22 '20 at 02:46
  • I meant *inverse transform* the point cloud (transform the point cloud using the inverse matrix of the camera pose), not *inverse transposing* (I don't even know what it is), my bad. – Jing Zhao Jul 22 '20 at 12:38
  • 8
    The window just remains empty for me when I use this code? – aviator Aug 24 '21 at 16:35
  • 1
    Running into same issue as @aviator. Window is blank and then when I start pressing buttons, the window hangs. – Hassan Hayat Jan 02 '22 at 02:21
  • 3
    Ok, turns out it works if the geometry already had the points defined when calling add_geometry(geometry). So, I added a little flag to say, if this is the first iteration, call add_geometry, otherwise call update_geometry. And now it works. Weird – Hassan Hayat Jan 02 '22 at 02:27
  • 3
    @TheSeamau5, that didn't fix for me, remains empty some why. – Ilya.K. Feb 27 '22 at 22:34
  • @Illya. K. https://stackoverflow.com/questions/70842338/playing-sequence-of-ply-files-in-open3d This should work – Mour_Ka Jun 24 '22 at 08:09
  • But now after Ireach this point and only finding that it is possible to add boxes using geometry.add_geometry(bbox) and doing a loop through clusters. The result is correct but so slow. Each add_geometry is slowing each frame from 0.022 sec to 0.5 sec. I started to think that Open3D is not a good library as it is claimed to be the most updatable one. – Mour_Ka Jun 24 '22 at 08:11