pythonopen3d

Calls to Open3D ViewControl seemingly have no effect on visualization yet calls to render options do?


I my short code example:

import numpy as np
import open3d as o3d

points_x = np.random.uniform(0, 1, (100, 3))
points_x[:, 1:] = 0
points_y = np.random.uniform(0, 1, (100, 3))
points_y[:, [0, 2]] = 0
points_z = np.random.uniform(0, 1, (100, 3))
points_z[:, :2] = 0

colors_x = np.zeros((100, 3))
colors_x[:, 0] = 1.0
colors_y = np.zeros((100, 3))
colors_y[:, 1] = 1.0
colors_z = np.zeros((100, 3))
colors_z[:, 2] = 1.0

points = np.concatenate((points_x, points_y, points_z), axis=0)
label_colors = np.concatenate((colors_x, colors_y, colors_z), axis=0)

# Create the point cloud object
pcd = o3d.geometry.PointCloud()
pcd.points = o3d.utility.Vector3dVector(points)
pcd.colors = o3d.utility.Vector3dVector(label_colors)

# Create visualizer object
vis = o3d.visualization.Visualizer()
vis.create_window()

# Add point cloud to the visualizer
vis.add_geometry(pcd)

# Set the point size
ro = vis.get_render_option()
ro.point_size = 2

# Try to alter the camera view
ctr = vis.get_view_control()
ctr.set_front([0, 0, 1])
ctr.set_up([1, 0, 0])
ctr.set_zoom(1.5)

# Run the visualization
vis.run()

# Clean up
vis.destroy_window()

I have been attempting to display a point cloud and set a specific viewing geometry of the cloud. I have tried many ways of getting and calling various functions of the ViewControl/Visualizer.get_view_control to do so. Though, none seem to have any effect. Interestingly, get_render_option().point_size does have an effect.

Why aren't my calls to ViewControl having an effect?


Solution

  • Did you use the open3d version==0.17.0?

    I replaced open3d version 0.17.0 with 0.16.0 and ctr worked!

    Command:

    pip install open3d==0.16.0