isl-org / Open3D

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

Add update_geometries function for gui.SceneWidget #6643

Open harrydobbs opened 9 months ago

harrydobbs commented 9 months ago

Checklist

Proposed new feature or change

Could the ability to update geometries please be added to the gui.SceneWidget? At the moment it appears that the work around is to remove_geometry then add it back with add_geometry. However this takes a bit of time to complete (with larger point clouds).

This issue has been referenced before (#issue_6430) , but has been marked as resolved - however I believe the current fix is just temporary. As, In the Example , there is a comment on line 379:

TODO(ssheorey) Switch to update_geometry() after #3452 is fixed.

Thanks.

References

No response

Additional information

No response

jtcook2 commented 9 months ago

open3d.visualization.gui.SceneWidget has a member "scene" of type open3d.visualization.rendering.Open3DScene. open3d.visualization.rendering.Open3DScene also has a member "scene" which I believe is of type open3d.visualization.rendering.Scene.

The issue seems to arise in open3d.visualization.rendering.Scene. Its add_geometry can take arguments of type open3d.cpu.pybind.t.geometry.Geometry (which I think is an abstract base class). open3d.cpu.pybind.t.geometry.PointCloud is also a open3d.cpu.pybind.t.geometry.Geometry or inherits from this class.

The problem is that the update_geometry can only accept open3d.cpu.pybind.t.geometry.PointCloud while add_geometry is more flexible by accepting open3d.cpu.pybind.t.geometry.Geometry. With this setup, point clouds can leverage the update_geometry method but meshes can not.

For meshes, you have to either remove_geometry and then re add_geometry or sample the mesh to generate a point cloud as a work-around (although unsatisfying). Removing and re-adding meshes is very slow.

It seems like an easy fix would be to just change update_geometry to accept arguments of type open3d.cpu.pybind.t.geometry.Geometry. Not sure how easy that is.

See the following link for the doctoring https://www.open3d.org/docs/release/python_api/open3d.visualization.rendering.Scene.html

Curious if anyone else has found other work arounds?

This issue has been raised but for some reason was closed https://github.com/isl-org/Open3D/issues/2869

An example of using update_geometry on a point cloud can be found here: https://github.com/isl-org/Open3D-ML/blob/3d13bfe4925204ee9a63bed3fad2f1f925e1ca8b/ml3d/vis/visualizer.py#L1108

jtcook2 commented 9 months ago

I've discovered this by accident. But it looks like if you update the pose of a mesh in a scene using

open3d.visualization.gui.SceneWidget.scene.set_geometry_transform(name, Transform) somewhere in "Callback" with open3d.visualization.gui.Application.instance.post_to_main_thread(window, Callback)

then you don't actually need to use the update_geometry method. This seems to be working for me right now.