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

How to save draw_geometries output as png or jpg #1095

Closed
rupeshchandgude opened this issue Jul 30, 2019 · 12 comments
Closed

How to save draw_geometries output as png or jpg #1095

rupeshchandgude opened this issue Jul 30, 2019 · 12 comments
Labels

Comments

@rupeshchandgude
Copy link

Is there any way to save output of draw_geometries as jpg or png format in python?

@Nerolf05
Copy link

Nerolf05 commented Aug 6, 2019

This tutorial should be helpful: customized visualization then go to "Capture images in a customized animation"
The example shows the "vis.capture_screen_float_buffer(False)" Method to take a screenshot, which could be saved using the "plt.imsave()" Method.

@Nerolf05
Copy link

Nerolf05 commented Aug 6, 2019

I have an additional question.
Is there a way to close my visualizer/figure? I want to make a movie of my pointcloud at different epochs using python.

Thanks in advance

@rupeshchandgude
Copy link
Author

I have an additional question.
Is there a way to close my visualizer/figure? I want to make a movie of my pointcloud at different epochs using python.

Thanks in advance

Thanks @Nerolf05 .I also stuck in that point. I am able to store the image once I close the visualizer output. I have to deploy my code on server,where I may not able to close the visualizer output manually. I get to know how to hide window by (vis.create_window(visible = False)), but after loading pcd to it, if we run "vis.run()" command terminal gets hang.

@rupeshchandgude
Copy link
Author

rupeshchandgude commented Aug 6, 2019

@Nerolf05 Currently I am able to store depth image, but the same logic fails for storing RGB image, it gives current screenshot as a image.
I use following code for depth :
vis = o3d.visualization.Visualizer() ; vis.create_window(visible = False) ; vis.add_geometry(pcd) ; depth = vis.capture_depth_float_buffer(True) ; plt.imshow(np.asarray(depth))
For RGB image :
vis = o3d.visualization.Visualizer() ; vis.create_window(visible = False) ; vis.add_geometry(pcd) ; img = vis.capture_screen_float_buffer(True); plt.imshow(np.asarray(img))

I use " ; " for new line, as code is print in wrong format. Sorry for that.

@Nerolf05
Copy link

Nerolf05 commented Aug 6, 2019

@rupeshchandgude i use vis.capture_screen_image(path, do_render) to capture the screen.

I also tried to close the Visualizer with a second Process, but i wasnt able to do it successfully.

@rupeshchandgude
Copy link
Author

@Nerolf05 Maybe we should try to find the way to close that window programmatically, so the code will go further to save output.

@rupeshchandgude
Copy link
Author

@Nerolf05 Following function can be used to store image without visualizer output .

vis = o3d.visualization.Visualizer()
vis.create_window()
vis.add_geometry(pcd)
vis.update_geometry()
vis.poll_events()
vis.update_renderer()
vis.capture_screen_image(path)
vis.destroy_window()

@ArashJavan
Copy link

Hello, sorry, but i have to repoen this issue, because the proposed method by @Nerolf05 raises following exception:

    vis.update_geometry()
TypeError: update_geometry(): incompatible function arguments. The following argument types are supported:
    1. (self: open3d.open3d.visualization.Visualizer, arg0: open3d.open3d.geometry.Geometry) -> bool

@alainchau
Copy link

@ArashJavan The following should work on v0.10.0:

vis = o3d.visualization.Visualizer()
vis.create_window()
vis.add_geometry(pcd)
vis.update_geometry(pcd)
vis.poll_events()
vis.update_renderer()
vis.capture_screen_image(path)
vis.destroy_window()

@szat
Copy link

szat commented Mar 30, 2021

For anyone that wonders: to get the depth map into a local variable without displaying:

vis = o3d.visualization.Visualizer()
vis.create_window(visible=False)
vis.add_geometry(mesh)
vis.update_geometry(mesh)
vis.poll_events()
vis.update_renderer()
depth = vis.capture_depth_float_buffer(do_render=False)
vis.destroy_window()

@Stchena
Copy link

Stchena commented Jan 31, 2022

If your screenshots turn out dark/black/without anything, you're probably missing the do_render option inside your capture_screen_image call

@happyiminjay1
Copy link

happyiminjay1 commented Apr 25, 2024

For rendering as an image this is the final version.

vis = o3d.visualization.Visualizer()
vis.create_window(visible=False)
vis.add_geometry(mesh)
vis.update_geometry(mesh)
vis.poll_events()
vis.update_renderer()
vis.capture_screen_image('f{i}.png',do_render=True)
vis.destroy_window()

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

No branches or pull requests

7 participants