Omni.kit.viewport error

from isaacsim import SimulationApp

# Isaac Sim uygulamasını başlat
simulation_app = SimulationApp({
    "headless": False,
    "open_usd": "C:\\Users\\dogan\\AppData\\Local\\ov\\pkg\\isaac-sim-4.2.0\\usd\\myproject12.usd"
})

import numpy as np
from PIL import Image
import random
import time
import omni  
from pxr import Gf  # Gf modülünü ekleyin

# Kameraların yollarını tanımla
camera_paths = [
    '/World/Camera',
    '/World/Camera_01',
    '/World/Camera_02',
    '/World/Camera_03'
]

# Farklı simülasyon senaryoları için kaç tekrar yapılacak
num_scenarios = 5

# Çöplerin pozisyonlarını rastgele ayarlamak için fonksiyon
def randomize_trash_positions(trash_objects):
    stage = omni.usd.get_context().get_stage()
    for trash in trash_objects:
        obj_prim = stage.GetPrimAtPath(trash)
        random_pos = [random.uniform(-5, 5), random.uniform(-5, 5), 0]  # Zemin üzerinde rastgele yerleştir
        # random_pos'u Gf.Vec3d türüne dönüştür
        obj_prim.GetAttribute("xformOp:translate").Set(Gf.Vec3d(*random_pos))

# Dummy camera angle function
def randomize_camera_angle(camera_path):
    pass  # Buraya kameranın açısını rastgele ayarlama kodunu ekleyin

trash_paths = [
    '/World/trash_01',
    '/World/trash_02',
    '/World/trash_03'
]

for scenario in range(num_scenarios):
    print(f"Senaryo {scenario + 1}: Başlatılıyor...")

    # Çöplerin pozisyonlarını rastgele ayarla
    randomize_trash_positions(trash_paths)

    for i, camera_path in enumerate(camera_paths):
        # Kameranın açısını rastgele ayarla
        randomize_camera_angle(camera_path)

        # Kamerayı al
        camera_prim = omni.usd.get_context().get_stage().GetPrimAtPath(camera_path)

        # Görüntüyü yakala
        viewport = omni.kit.viewport.get_viewport(camera_prim.GetPath())
        viewport_image = viewport.get_image()  # Görüntü alma
        np_image = np.array(viewport_image)  # Görüntüyü numpy array'e çevir

        # Görüntüyü kaydet
        img = Image.fromarray(np_image)  # Numpy array'den image objesi oluştur
        img.save(f'scenario_{scenario + 1}_camera_{i + 1}.png')  # Görüntüyü bir PNG dosyası olarak kaydet

        print(f"Senaryo {scenario + 1}, Kamera {i + 1}: Görüntü alındı ve kaydedildi.")

    time.sleep(2)

# Isaac Sim uygulamasını kapat
simulation_app.close()

when ı had run this code ı get this error:

Please take a look at the following documentation:

https://docs.omniverse.nvidia.com/isaacsim/latest/ros_tutorials/tutorial_ros_camera_publishing.html#isaac-sim-app-tutorial-ros-camera-publishing
https://docs.omniverse.nvidia.com/kit/docs/omni.kit.viewport.docs/latest/viewport_api.html

Hi!
May I ask if you solved the problem?I got the available viewport through omni.kit.viewport.utility.get_active_viewport(), so I didn’t get an error at the line of code where you reported an error, but at the next line, where the get_image() function reported an error, with the message:

AttributrError: 'ViewportAPI' object hao no attribute 'get_image'

I don’t know if you can read and save the image smoothly now.The official link given below is not quite the same as in my case, I created the camera directly in the usd file and only need to read the image in my standalone code, so I’m inclined to use your way of doing it.
A million thanks if you can help me out!