搭载Isaac Sim 5.1的相机
我创建了一个包含相机及其他对象的USD文件。
我还使用BasicWriter将从相机看到的当前图像写入磁盘。
似乎没有办法获取从相机看到的图像,以避免将其写入磁盘。
在Isaac Sim 5.1中,这个版本没有omni.replicator.core.capture或类似的属性。
是否有其他方法在不将图像写入磁盘的情况下获取它?
解决方案
Isaac Sim 5.1提供了 isaacsim.sensors.camera.Camera 类,你可以参考此处的文章,其中包含直接的内存访问接口。
你可以尝试如下实现
from isaacsim import SimulationApp
simulation_app = SimulationApp({"headless": False})
from isaacsim.sensors.camera import Camera
from isaacsim.core.api import World
import numpy as np
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=(1280, 720),
)
my_world.reset()
camera.initialize()
# Wait a few frames for the renderer to warm up
for _ in range(5):
my_world.step(render=True)
# Grab the image directly as a NumPy array — no disk I/O
rgba_image = camera.get_rgba() # shape: (H, W, 4), dtype: uint8
rgb_image = camera.get_rgb() # shape: (H, W, 3), dtype: uint8
另一种方法是在内存中直接附加一个标注器并调用.get_data()
示例
import omni.replicator.core as rep
import numpy as np
# Attach to your existing camera prim path
render_product = rep.create.render_product("/World/camera", (1280, 720))
# Create an RGB annotator and attach it
rgb_annotator = rep.AnnotatorRegistry.get_annotator("rgb")
rgb_annotator.attach([render_product])
# In your sim loop:
rep.orchestrator.step(rt_subframes=1)
# Get the data directly as a NumPy array — no BasicWriter, no disk
data = rgb_annotator.get_data()
image_array = data["data"]
站内所有文章版权归属LeftHeroAI导航站,无授权禁止任何主体转载、抄袭、复制内容,亦不得私自架设镜像站点。一经侵权,本站将通过法律途径追责。