How do you take pictures inside an existing environment in isaac sim 4.5.0 without it crashing?

I’m using isaac sim 4.5.0 and am attempting to record a data set but my sim keep crashing when I attempt to take a picture. Here is the code I’m using:

Import the omniverse kit extension system instead of creating a new SimulationApp

import omni.kit.app
import omni.usd

Import other necessary modules

from isaacsim.sensors.camera import Camera
import numpy as np
import matplotlib.pyplot as plt
import isaacsim.core.utils.numpy.rotations as rot_utils
import os

Get the existing stage that’s already loaded in the running Isaac Sim

stage = omni.usd.get_context().get_stage()

Add a camera to the existing stage

camera = Camera(
prim_path=“/World/camera”,
position=np.array([0.0, 0.0, 25.0]),
frequency=20,
resolution=(256, 256),
orientation=rot_utils.euler_angles_to_quats(np.array([0, 90, 0]), degrees=True),
)

Initialize the camera in the existing environment

camera.initialize()

Wait for a few frames to make sure the camera is properly set up

import omni.kit.app
for i in range(5):
# This advances the render frame in the existing application
omni.kit.app.get_app().update()

Now capture the image

rgba_data = camera.get_rgba()
print(“RGBA data shape:”, rgba_data.shape)
rgb_data = rgba_data[:, :, :3] # Extract just the RGB channels

Save the image to file

output_path = os.path.expanduser(“~/isaacsim_current_environment_capture.png”)
plt.imsave(output_path, rgb_data)
print(f"Image saved to: {output_path}")

Optional: Clean up the camera when done

Note that we’re not closing the application since it was already running

camera.release()

I already have a custom environment created with a saved .USD file. I would like to take pictures of this environment with the Isaac sim camera.

Have you checked the log file for any error messages or warnings that might provide clues about the crash?