Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

non-blocking VisualizerWithEditing #1605

Closed
markkorput opened this issue Mar 12, 2020 · 4 comments
Closed

non-blocking VisualizerWithEditing #1605

markkorput opened this issue Mar 12, 2020 · 4 comments

Comments

@markkorput
Copy link

Is your feature request related to a problem? Please describe.
It would be great to be able to pick points from a pointcloud (and perform other operations), without blocking your application. When I use VisualizerWithEditing and try to run it non-blocking mode (see code below), it crashes as soon as I pick a point using shift+click (see log below).

Describe the solution you'd like
It would be great to have a fully functional non-blocking VisualizerWithEditing.

Describe alternatives you've considered
I considered using the 'normal' blocking version of VisualizerWithEditing in a separate thread, but since it would still be blocking on the separate thread, there would be no way to update geometry when things in other parts of the application change, or close the Visualizer when needed.

Additional context
current code

def setup(self):
  self.vis = o3d.visualization.VisualizerWithEditing()      
  self.vis.create_window()
  self.vis.add_geometry(self.pcd)

def update(self):
  # without the line below visualization works, only crashes after picking a point
  # WITH the line below, application freezes with black visualization window
  # self.vis.update_geometry(source)  
  self.vis.poll_events()
  self.vis.update_renderer()

crash log

[Open3D INFO] Picked point #142192 (1, 0.18, 3.4) to add in queue.
Segmentation fault: 11
@germanros1987
Copy link
Contributor

Hi @markkorput,

We are working on a new version of the Visualizer. I will add a non-blocking version of an editing tool to our roadmap.

@MaxChanger
Copy link

Is there any new progress regarding this feature?

@prewettg
Copy link
Contributor

The new visualizer is available in 0.12, it is open3d.visualization.O3DVisualizer. You can see some examples in examples/python/gui; more examples have been added to the master branch and will be available in 0.13. The examples/python/gui/draw.py example shows how to use picking (it uses the draw() function, which is the equivalent of draw_geometries() for the new GUI, but draw() uses O3DVisualizer underneath; in fact, you can look at python/open3d/visualization/draw.py for another example of O3DVisualizer.

We are working on a better way of running O3DVisualizer non-blocking, but for now there are two approaches. One is illustrated in examples/python/gui/add-geometry.py, where you start a thread to do all the processing, call gui.Application.instance.run() on the main thread, and then use gui.Application.instance.post_to_main_thread to post a function to update the GUI as necessary. Another way, which does not have an example at the moment, is similar to the old visualizer:

def main():
    app = o3d.visualization.Application.instance
    app.initialize()
    vis = o3d.visualization.Open3DVisualizer("Non-blocking", 1024, 768)
    # add everything here
    while app.run_one_tick():
        # do whatever you need to here
        vis.post_redraw()  # request a redraw, assuming anything changed

This way is simpler, but the GUI won't process events like mouse events outside of run_one_tick(), so you'll need to make sure that the body of the loop finishes quickly. (But, this is no different than what to old visualizer does.)

@parthnatekar
Copy link

Hi, can you add a tutorial of the non-blocking interactive visualizer?

I currently have a non-blocking visualizer working and want to make it interactive without overhauling it completely.

Any suggestions?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants