isl-org / Open3D

Open3D: A Modern Library for 3D Data Processing
http://www.open3d.org
Other
11.43k stars 2.31k forks source link

open3d.visualization.Visualizer.get_render_option() return NoneType Object #6763

Open data-hound opened 6 months ago

data-hound commented 6 months ago

Checklist

Describe the issue

I have been trying to reproduce the example custom_draw_geometry_with_camera_trajectory in the docs. But, I keep getting error: AttributeError: 'NoneType' object has no attribute 'load_from_json'

Steps to reproduce the bug

import open3d as o3d 
import numpy as np 
import matplotlib.pyplot as plt
import os

ply_point_cloud = o3d.data.PLYPointCloud()
pcd = o3d.io.read_point_cloud(ply_point_cloud.path)

cus_viz_demo = o3d.data.DemoCustomVisualization()

my_viz = o3d.visualization.Visualizer()
pcd.paint_uniform_color([0.5, 0.5, 0.5])
my_viz.add_geometry(pcd)

my_viz.get_render_option().load_from_json(cus_viz_demo.render_option_path)

Error message

Cell 10 line 5 3 my_viz.add_geometry(pcd) 4 # ro = my_viz.get_render_option() ----> 5 my_viz.get_render_option().load_from_json(cus_viz_demo.render_option_path)

AttributeError: 'NoneType' object has no attribute 'load_from_json'

Expected behavior

open3d.visualization.RenderOption object should be returned

Open3D, Python and System information

- Operating system: Ubuntu 20.04 
- Python version: Python 3.9
- Open3D version: output from python: 0.18
- System architecture: x86 
- Is this a remote workstation?: yes
- How did you install Open3D?: pip 
- Compiler version (if built from source): gcc 7.5 / clang 7.0

Additional information

No response

nicolaloi commented 5 months ago

You should first call my_viz.create_window(). This is the revised code:

import open3d as o3d 
import numpy as np 
import matplotlib.pyplot as plt
import os

ply_point_cloud = o3d.data.PLYPointCloud()
pcd = o3d.io.read_point_cloud(ply_point_cloud.path)

cus_viz_demo = o3d.data.DemoCustomVisualization()

my_viz = o3d.visualization.Visualizer()
pcd.paint_uniform_color([0.5, 0.5, 0.5])
my_viz.create_window() # ADD
my_viz.add_geometry(pcd)

my_viz.get_render_option().load_from_json(cus_viz_demo.render_option_path)

my_viz.run()
my_viz.destroy_window()