Isaac Sim camera.get_rgb() outputs 1D array

Hello,

Im trying to load my stage in a standalone python, i finally managed to load it using omni.usd.open_stage(). Now the World object doesn’t have scene atribute, and the camera output is array with 0s. I attach the code

from omni.isaac.kit import SimulationApp
import omni
simulation_app = SimulationApp({"headless": False})
from omni.isaac.core.prims import XFormPrim
from omni.isaac.core.objects import DynamicCuboid
from omni.isaac.sensor import Camera
from omni.isaac.core import World
import omni.isaac.core.utils.numpy.rotations as rot_utils
import numpy as np
import matplotlib.pyplot as plt
from omni.isaac.core.utils.stage import add_reference_to_stage



usd_path="/home/maciek/Desktop/scene1.usd"
omni.usd.get_context().open_stage(usd_path)

my_world = World(stage_units_in_meters=1.0)

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),
)


#my_world.scene.add_default_ground_plane()
#my_world.reset()
camera.initialize()

i = 0
camera.add_motion_vectors_to_frame()

while simulation_app.is_running():
    my_world.step(render=True)
    print(camera.get_current_frame())
    if i == 100:
        print("") 
        #points_2d = camera.get_image_coords_from_world_points(
            #np.array([cube_3.get_world_pose()[0], cube_2.get_world_pose()[0]])
        #)
        #points_3d = camera.get_world_points_from_image_coords(points_2d, np.array([24.94, 24.9]))
        #print(points_2d)
        #print(points_3d)
        imgplot = plt.imshow(camera.get_rgba()[:, :, :3])
        plt.show()
        #print(camera.get_current_frame()["motion_vectors"])
    if my_world.is_playing():
        if my_world.current_time_step_index == 0:
            my_world.reset()
    i += 1


simulation_app.close()

Can you point me in good direction to obtain images from the camera ? Currently the imgplot gives error that they camera.get_rgba() array has 1 dimension

2 Likes

Hi there,

is the following example working for you and returning correct rgb images? It seems similar to your example.

Best,
Andrei

Hi @ahaidu @maciek.jankowski989 can you tell me what are the values 24.94 and 24.9 ? I also see these values in Camera — Omniverse IsaacSim latest documentation but no explains for that so I am really confused :((