Set custom viewport resolution

Hi,
I am using the viewport_api together with the SyntheticDataHelper to extract images from predefined cameras for my application. To this means I need to set the Camera resolution to a predefined value.

However when I create a viewport window in a StandaloneApplication and set the desired resolution, after every call to SimulationApp.Update() the viewport_api resolution is reset to the default value.
The Debug stack shows that this is caused by the Viewport-Window Menubar, which calls the resolution setter in its _on_current_item_changed callback and thereby resets the resolution back to the default value. (See attached screenshot)

Can I disable the menubar in the viewport-window I am creating, or avoid this issue in any other way?

Thanks
Thomas

camera = create_camera_prim(camera_prim_path, position, orientation, attributes)

viewport_resolution = (800, 400)
window_width = viewport_resolution[0]
window_height = viewport_resolution[1]

viewport_window = create_viewport_window(
        name=window_name,
        position_x=0.0,
        position_y=0.0,
        width=window_width,
        height=window_height,
        camera_path=camera_prim_path,
    )

viewport_window.viewport_api.set_active_camera(camera_prim_path)
viewport_window.viewport_api.resolution = viewport_resolution

viewport_window.viewport_api.set_active_camera(camera_prim_path)
viewport_window.viewport_api.resolution = viewport_resolution
resolution_before_update = viewport_window.viewport_api.resolution
simulation_app.update()
resolution_after_update_1 = viewport_window.viewport_api.resolution
simulation_app.update()
resolution_after_update_2 = viewport_window.viewport_api.resolution


Hi @ManicMunchkin. Looks like this is more specifically an Isaac Sim issue so I’ve moved this topic to that forum.

Hi there,

you can use the Replicator API for accessing synthetic data:

Or using the camera sensor:

Hi
thanks for pointing me towards the Camera Sensor! That somewhat simpllifies my code.
However I still would like to preview the camera image in a viewport, for which I would need to adapt the viewport resolution accordingly.
Does the viewport-resolution setting need to be applied after every world reset?

Regards
Thomas

Hi!
I also wanted to create a camera viewport to get its image, but I never found out which python api I could use to change the resolution of the viewport, I found the answer here, thank you very much!
Also, I’ve noticed that every time I reset the world, the resolution changes back to 1280*720, so I need to set the resolution every time, and while this works for the needs, have you found how to set the resolution to a fixed value once and for all? Thanks!

Hello,

I have found a way to solve a stupid but easy and useful method to set the resolution to a fixed value once and for all. It works for my ask.
You can set manually the resolution of the viewport with UI of Isaac Sim. And the resolution will not change. But it will change when you re-create the viewport. But if you create the viewport only once, i think this method will work for you too.