Open3d: Cannot control the viewer when updating the geometry

Created on 11 Jan 2019  路  3Comments  路  Source: intel-isl/Open3D

Hi, I wrote the following code for realtime visualization of point cloud. But it seems that I cannot use mouse to rotate the view in the visualizer after the window shows up. It can be reproduced with the following code. I am using open3d 0.4. Can anyone help? Thanks.

import open3d
import numpy as np
import time

vis = open3d.Visualizer()
vis.create_window("3D Map")
pcd = open3d.PointCloud()
pts = np.mgrid[1: 6: complex(100), 
      2: 9: complex(100), 
      3: 6: complex(100)].reshape(3, -1).T
a = 1
start = time.time()
coord = open3d.create_mesh_coordinate_frame(1, [0, 0, 0])
coord_x = 0
vis.add_geometry(pcd)
while True:
    start_time = time.time()
    pcd.clear()
    coord.clear()
    pts[:, 0] = pts[:, 0] + 0.1
    pcd.points = open3d.Vector3dVector(pts)
    coord_x += 0.2
    coord = open3d.create_mesh_coordinate_frame(1, [coord_x, 0, 0])
    vis.add_geometry(coord)
    vis.update_geometry()
    vis.poll_events()
    vis.update_renderer()
    if time.time() - start > 30:
        break
    end_time = time.time()
    process_time = end_time - start_time
    print("Updating FPS = {0}".format(1.0 / process_time))
    print('Processing time:', process_time)
vis.destroy_window()
question

Most helpful comment

Hi @taochenshh. The issue is came from vis.add_geometry(coord) in the while loop. Once a new geometry is added, Visualizer resets viewpoint automatically. As a result, you will feel like the mouse control does not work.

The key idea to fix this issue is to use vis.add_geometry(coord) just once. For example,

#########################################
# original code written by taochenshh
#########################################
while True:
     :
     coord = open3d.create_mesh_coordinate_frame(1, [coord_x, 0, 0])
     vis.add_geometry(coord)
     :

Try like this

###############################
# suggested code
###############################
vis.add_geometry(coord)
while True:
     :
     temp = open3d.create_mesh_coordinate_frame(1, [coord_x, 0, 0])
     coord.vertices = temp.vertices
     coord.triangles = temp.triangles
     :

With this change, I was able to change the viewpoint.

All 3 comments

Hi @taochenshh. The issue is came from vis.add_geometry(coord) in the while loop. Once a new geometry is added, Visualizer resets viewpoint automatically. As a result, you will feel like the mouse control does not work.

The key idea to fix this issue is to use vis.add_geometry(coord) just once. For example,

#########################################
# original code written by taochenshh
#########################################
while True:
     :
     coord = open3d.create_mesh_coordinate_frame(1, [coord_x, 0, 0])
     vis.add_geometry(coord)
     :

Try like this

###############################
# suggested code
###############################
vis.add_geometry(coord)
while True:
     :
     temp = open3d.create_mesh_coordinate_frame(1, [coord_x, 0, 0])
     coord.vertices = temp.vertices
     coord.triangles = temp.triangles
     :

With this change, I was able to change the viewpoint.

Thanks.

@syncle how can i set the view point in the middle of the window without reseting continiously?
i am dealing with point clouds of car's lidar and when i drive towards outside the window, point clouds disappear and went out the window frame.

Was this page helpful?
0 / 5 - 0 ratings