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:
- F10 Hotkey will do a simple screen capture with capture setting defined under
Preferences
- Movie Capture extension does both current frame capture but also sequence capture should you need to render out a clip of simulation/animation - Movie Capture — Omniverse Extensions latest documentation
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")
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.