Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot control the viewer when updating the geometry #770

Closed
taochenshh opened this issue Jan 11, 2019 · 3 comments
Closed

Cannot control the viewer when updating the geometry #770

taochenshh opened this issue Jan 11, 2019 · 3 comments
Labels

Comments

@taochenshh
Copy link

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()
@syncle
Copy link
Contributor

syncle commented Jan 11, 2019

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.

@taochenshh
Copy link
Author

Thanks.

@yigitkaraduman
Copy link

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants