Save an image from the viewport of a camera in Isaac Sim

Now I have added a camera to the scene, and I can see the viewport of the camera in the GUI, but how can I save the image from the viewport of the camera in python. I’d appreciate it if anyone can teach me.

@1710211475 i am just another user, but you could try looking into the viewport utility:

here’s the viewport API - https://docs.omniverse.nvidia.com/kit/docs/omni.kit.viewport.docs/latest/viewport_api.html#capturing-viewport-frames

in addition, there are few other ways to grab viewport via hotkey/GUI:

2 Likes

Here’s the python code to capture the viewport:

from omni.kit.viewport.utility import get_active_viewport, capture_viewport_to_file

vp_api = get_active_viewport()
capture_viewport_to_file(vp_api, r"C:\temp\screenshot.png")
2 Likes

Hi!
I found that this code you provided seems to work only in script editor’s mode, I run this code in standalone mode and it doesn’t seem to do anything and no error is reported, but it doesn’t save the image either, how should I save the image from a specific camera in standalone mode?
Thanks!

I do not recommand using replicator but I do use rep.WriterRegistry to write data to my system every frame.