Reputation: 81
I have this toy example where i want to change the default view while calling the visualizer.run(), for example i want to change the default values of zoom , rotate and scale of the scene in the visualizer. Any help will be appreciated
import sys
import numpy as np
import open3d as o3d
# cloud = o3d.geometry.PointCloud()
ply_point_cloud = o3d.data.PLYPointCloud()
pcd = o3d.io.read_point_cloud(ply_point_cloud.path)
visualizer = o3d.visualization.Visualizer()
visualizer.create_window()
visualizer.add_geometry(pcd)
view_ctl = visualizer.get_view_control()
# view_ctl= view_ctl.convert_to_pinhole_camera_parameters() # noqa: E501
view_ctl.scale(0)
visualizer.update_renderer()
visualizer.run()
Upvotes: 1
Views: 534
Reputation: 4574
The code is fine (tested and results below) however, I am pretty sure you are using version 0.17.0. Move to version 0.18.0
or more recent developer releases where this bug has been fixed. Install from here.
P.S. Root issue is due to get_view_control
returning a copy of ViewControl
of Visualizer
and hence any changes to it does not affect the Visualizer
.
import numpy as np
import open3d as o3d
points = np.random.rand(30000, 3) * [1,2,3]
colors = np.random.rand(30000, 3)
pcd = o3d.geometry.PointCloud()
pcd.points = o3d.utility.Vector3dVector(points)
pcd.colors = o3d.utility.Vector3dVector(colors)
visualizer = o3d.visualization.Visualizer()
visualizer.create_window()
visualizer.add_geometry(pcd)
view_ctl = visualizer.get_view_control()
view_ctl.camera_local_translate(forward=0, right=0.5, up=0)
visualizer.update_renderer()
visualizer.run()
This produces a left shifted image instead of keeping pointcloud in center -
Upvotes: 1