isl-org/Open3D

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

data-hound opened this issue · 1 comments

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

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()