I’m trying to understand how to make the annotator for instance ID segmentation work in my extension. My extension does not directly use replicator, and I’m not sure if it’s needed. Examples such as this or this or this are not directly useful. I am currently instantiating a Camera
from omni.isaac.sensor
and I am able to access RGB and Depth. I called initialize()
on the camera in my “on play” callback, and I’ve registered annotators using the methods on the camera object, like so:
def on_play(self):
for camera in self.cameras:
camera.initialize()
camera.add_instance_id_segmentation_to_frame()
camera.add_distance_to_image_plane_to_frame()
But the segmentation data is all zeros or all ones! Below is a snippet of code showing how I get the images. This happens inside of on_physics_step
. I can tell that something is almost working because the ‘idToLabels’ values change as the camera moves and different objects go in and out of view, but the values are something like: {'19': 'INVALID', '40': 'INVALID', '66': 'INVALID', '71': 'INVALID', '65': 'INVALID', '70': 'INVALID', '80': 'INVALID', '29': 'INVALID', '21': 'INVALID'}
for camera in self.cameras:
frame_dict = camera.get_current_frame()
rgba = frame_dict.get('rgba')
instance_id_seg = frame_dict.get('instance_id_segmentation')
depth = frame_dict.get('distance_to_image_plane')
if rgba is not None:
rgb = rgba[..., :3].astype(np.uint8)
rr.log(f"camera/{camera.name}/rgb", rr.Image(rgb).compress(95))
if instance_id_seg is not None:
segmentation = instance_id_seg['data']
id_to_labels = instance_id_seg['info']['idToLabels']
print(len(id_to_labels), np.unique(segmentation))
One thing that makes this work to:
- Load my plugin
- Load the script editor and paste in the replicator demo from here
- Click “Run” on the script, which creates a few new things in the scene including a SGDPipeline (what is this?)
- Click Play to run isaac sim, which seems to run both the replicator code and my extension. This results in a valid instance id segmentation! But why?
Some of my questions are:
- What is this replicator script doing that I need to be doing in my extension?
- Why does the rgb and depth annotators work without any fuss? What makes the instance id segmentation annotator different?
- Is there an example code showing how to use annotators without base the project entirely around replicator? My project is primarily based around cumotion and use a custom extension, and I’m not using the replicator workflow.
Isaac Sim Version
4.2.0
Operating System
Ubuntu 22.04