2. Synthetic Data Recorder

2.1. Learning Objectives

This tutorial introduces the Synthetic Data Recorder for Omniverse Isaac Sim, a GUI extension for recording synthetic data with the possibility of using custom Replicator writers to record the data in any custom format.

15-20 Minute Tutorial

2.2. Getting Started

The tutorial uses the following stage as an example:

Isaac/Samples/Replicator/Stage/full_warehouse_worker_and_anim_cameras.usd

Synthetic Data Recorder

The example stage comes preloaded with semantic annotations, as well as multiple cameras, a few of them being animated to move around the scene when running the simulation. To create custom camera movement animations take a look at the Camera Animation Tutorial.

Note

When using other scenes make sure to add semantic annotations to the scene otherwise most annotators (semantic_segmentation, 3d_bounding_box, etc.) will not be able to produce data.

2.3. Basic Usage

The recorder is split into two main parts: the Writer frame - containing sensor, data, and output parameters; and the Control frame - containing the recording functionalities such as start, stop, pause, and parameters such as the number of frames to execute.

Synthetic Data Recorder Window

2.3.1. Writer Parameters

The Render Products frame creates a list of render product entries using the Add New Render Product button. By default a new entry is added to the list using the active viewport camera as its camera path (see left figure). If however cameras are selected in the stage viewer, these are added to the render products list (see right figure). The render products list can contain the same camera path multiple times, however each time with a different resolution. All the entry values (camera path or resolution) can also be manually edited in the input fields.

Synthetic Data Recorder Render Products

The Parameters frame gives the possibility to choose between the default built-in Replicator writer (BasicWriter) or to choose a custom writer. The default writer parameters (mostly annotators) can be selected from the checkbox list. As custom writers have unknown parameters, these can be provided by the user in form of a json file containing all the required parameters. The path to the json file can be added in the Parameters Path input field.

Synthetic Data Recorder Parameters

The Output frame (left figure) contains the working directory path where the data will be saved together with the folder name used for the current recording. By selecting between Overwrite, Increment, or Timestamp the output folder name can be kept the same or modified to avoid overwriting previous recordings. The Overwrite option will maintain the output path and write over any existing data. The Increment option will start by appending _0 to the folder name and increment it by 1 for each recording. The Timestamp option will append a timestamp (_YYYY-mm-dd-HH-MM-SS) to the folder name. The recorder can also write to S3 buckets by checking Use S3 and providing the required fields and having the AWS credentials set up.

Note

When writing to S3 the Increment folder naming is not supported and will default to Timestamp.

The Config frame (right figure) can load and save the GUI writer state as a json config file. By default the extension loads the previously used configuration state.

Synthetic Data Recorder Output and Config

2.4. Control

The Control frame contains the recording functionalities such as Start/Stop and Pause/Resume, and parameters such as the number of frames to record, or the number of subframes to render for each recorded frame. The Start button will create a writer given the selected parameters and start the recording. The Stop button will stop the recording and clear the writer. The Pause button will pause the recording without clearing the writer, and the Resume button will resume the recording. The Number of frames input field will set the number of frames to record, after which the recorder will be stopped and the writer cleared. If the value is set to 0, the recording will run indefinitely until the Stop button is pressed. The RTSubframes field will set the number of additional subframes to render for each per frame. This can be used if randomized materials are not loaded in time or if temporal rendering artifacts (such as ghosting) are present due to objects being teleported. The Control Timeline checkbox will start/stop/pause/resume the timeline together with the recorder, after each recording the timeline is moved to timestamp 0.

Synthetic Data Recorder Output and Config

Note

In the current version, Replicator and Isaac Sim are both interacting with the timeline, and in some cases they can cause unwanted behavior. Some known issues are:

  • when running Replicator, the timeline’s loop mode is ignored

  • when using the Recorder the timeline should be controlled either through the Control Timeline flag or through the Isaac Sim GUI, not both

2.5. Custom Writer Example

In order to support custom data formats custom writer can be registered and loaded from the GUI. In this example, we register a custom writer called MyCustomWriter using the Script Editor and use it with the recorder.

MyCustomWriter
 1from omni.replicator.core import AnnotatorRegistry, BackendDispatch, Writer, WriterRegistry
 2
 3class MyCustomWriter(Writer):
 4    def __init__(
 5        self,
 6        output_dir,
 7        rgb = False,
 8        semantic_segmentation = False,
 9    ):
10        self.version = "0.0.1"
11        self.backend = BackendDispatch({"paths": {"out_dir": output_dir}})
12        if rgb:
13            self.annotators.append(AnnotatorRegistry.get_annotator("rgb"))
14        if semantic_segmentation:
15            self.annotators.append(AnnotatorRegistry.get_annotator("semantic_segmentation"))
16        self._frame_id = 0
17
18    def write(self, data):
19        if "rgb" in data:
20            filename = f"rgb_{self._frame_id}.png"
21            self.backend.write_image(filename, data["rgb"])
22        if "semantic_segmentation" in data:
23            filename = f"semantic_segmentation_{self._frame_id}.png"
24            self.backend.write_image(filename, data["semantic_segmentation"])
25        print(f"Frame {self._frame_id} written to {self.backend.output_dir}")
26        self._frame_id += 1
27
28    def on_final_frame(self):
29        print(f"Final frame {self._frame_id} reached")
30        self._frame_id = 0
31
32WriterRegistry.register(MyCustomWriter)
my_params.json
1{
2    "rgb": true
3}
Synthetic Data Recorder Custom Writer

2.6. Replicator Randomized Cameras

In order to take advantage of Replicator randomization techniques, these can be loaded using the Script Editor before starting the recorder to run scene randomizations during recording. In this example we create a randomized camera using Replicator API. This can be attached as a render product to the recorder and for each frame the camera will be randomized with the given parameters.

Randomized Camera
 1import omni.replicator.core as rep
 2
 3with rep.new_layer():
 4    camera = rep.create.camera()
 5    with rep.trigger.on_frame():
 6        with camera:
 7            rep.modify.pose(
 8                position=rep.distribution.uniform((-5, 5, 1), (-1, 15, 5)),
 9                look_at="/Root/SM_CardBoxA_3",
10            )
Synthetic Data Recorder Custom Writer

The following figure shows the steps by instructions on setting up a Replicator randomization and running it with the recorder.

Synthetic Data Recorder Custom Writer Steps