miscellaneous.offset_writer module#

Implements OV Writer with offset.

class miscellaneous.offset_writer.OffsetWriter(*args: Any, **kwargs: Any)#

Bases: Writer

Offset writer which is built upon <BasicWriter>, but has a frames offset before readout the frame. It assumes that stage content holds still for number of frames given by <frame_content_lifespan> before some change. This offset allows renderer to render everything properly and stabilize quality of RTX and DLSS. It has to be empirically determined what is a good offset for given scenario.

__name__#

Class name.

Type:

str

_MAX_FRAMES_OFFSET#

Defines the maximal allowed frames offset.

Type:

int

_WRITER_NUMBERING_PADDING#

Defines the leading zeros for saved files naming.

Type:

int

_output_dir#

Output directory string that indicates the directory to save the results.

Type:

str

_backend#

OV backend dispatcher.

Type:

BackendDispatch

_frame_id#

Frame index.

Type:

int

_image_output_format#

Output image format.

Type:

str

_content_lifespan#

Internal aux variable for the loop. Indicates how many frames passed since the last read out.

Type:

int

annotators#

List of annotators.

Type:

List[Any]

frame_read_out_num#

Defines frame number after which the frame is read out and saved. For <frame_content_lifespan> = 1 it is every frame. For <frame_content_lifespan> > 1, the value is <frame_content_lifespan> - 1. This is because we want to read the frame every <frame_content_lifespan>th frame.

Type:

int

content_lifespan_init_val#

Init value for the helper loop, to decide when to perform a new read out. Depends on <content_lifespan_init_val>. For single frame read out, it’s set to 0, otherwise to -1.

Type:

int

_MAX_FRAMES_OFFSET = 180#
_WRITER_NUMBERING_PADDING = 3#
__annotations__ = {'_MAX_FRAMES_OFFSET': <class 'int'>, '__sphinx_decorator_args__': 'Tuple[Any, ...]'}#
__init__(output_dir: str, semantic_types: Optional[List[str]] = None, rgb: bool = False, bounding_box_2d_tight: bool = False, bounding_box_2d_loose: bool = False, semantic_segmentation: bool = False, instance_segmentation: bool = False, distance_to_camera: bool = False, distance_to_image_plane: bool = False, bounding_box_3d: bool = False, occlusion: bool = False, normals: bool = False, motion_vectors: bool = False, camera_params: bool = False, image_output_format: str = 'png', colorize_semantic_segmentation: bool = True, colorize_instance_segmentation: bool = True, frame_content_lifespan: int = 1)#

output_dir (str): Output FS folder where to save data. semantic_types (Optional[List[str]], optional): Semantic classes to be kept. Defaults to None. rgb (bool, optional): True will generate RGB images. Defaults to False. bounding_box_2d_tight (bool, optional): True will generate 2D bboxes, not covering obscured object’s

parts. Defaults to False.

bounding_box_2d_loose (bool, optional): True will generate 2D bboxes, covering also obscured object’s

parts. Defaults to False.

semantic_segmentation (bool, optional): True will generate semantic segmentaion annotations.

Defaults to False.

instance_segmentation (bool, optional): True will generate instance segmentation annotations.

Defaults to False.

distance_to_camera (bool, optional): True will generate inverse depth map to camera. Defaults to False. distance_to_image_plane (bool, optional): True will generate inverse depth map to image plane.

This means, it’s not exact distance, but Z component of the distance. Defaults to False.

bounding_box_3d (bool, optional): True will generate 3D bounding boxes. Defaults to False. occlusion (bool, optional): TODO add the description. Defaults to False. normals (bool, optional): True will generate normals for each pixels in the image. Defaults to False. motion_vectors (bool, optional): True will generate motion vector of the pixels inside the image.

Defaults to False.

camera_params (bool, optional): True will store camera’s parameters (intrinsics, extrinsics).

Defaults to False.

image_output_format (str, optional): String that indicates the format of saved RGB images.

Defaults to “png”.

colorize_semantic_segmentation (bool, optional): If True, semantic segmentation is converted to an image

where semantic IDs are mapped to colors and saved as a uint8 4 channel PNG image. If False, the output is saved as a uint32 PNG image. Defaults to True

colorize_instance_segmentation (bool, optional): If True, semantic segmentation is converted to an image

where semantic IDs are mapped to colors and saved as a uint8 4 channel PNG image. If False, the output is saved as a uint32 PNG image. Defaults to True.

frame_content_lifespan (int, optional): Number of frames for which the scene content holds still and

no frames readout is performed. Defaults to 1.

semantic_types (List[str], optional): List of semantic types to consider when filtering annotator data.

Default: [“class”]

writer_name (str): OV Writer type name.

__name__ = 'OffsetWriter'#
__orig_bases__ = (omni.replicator.core.Writer,)#
_write_bounding_box_data(bbox_type: str, fs_relative_path: str, annotator_data: Any) None#

Writes bounding box data.

Parameters:
  • bbox_type (str) – Specifies bbox type.

  • fs_relative_path (str) – FS relative path where to save bounding box data.

  • annotator_data (str) – Annotator data.

_write_camera_params(fs_relative_path: str, annotator_data: Any) None#

Writes camera parameters data.

Parameters:
  • fs_relative_path (str) – FS relative path where to save camera parameters data.

  • annotator_data (str) – Annotator data.

_write_distance_to_camera(fs_relative_path: str, annotator_data: Any) None#

Writes distance to camera data.

Parameters:
  • fs_relative_path (str) – FS relative path where to save distance to camera data.

  • annotator_data (str) – Annotator data.

_write_distance_to_image_plane(fs_relative_path: str, annotator_data: Any) None#

Writes distance to image plane data.

Parameters:
  • fs_relative_path (str) – FS relative path where to save distance to image plane data.

  • annotator_data (str) – Annotator data.

_write_instance_segmentation(fs_relative_path: str, annotator_data: Any) None#

Writes instance segmentation data.

Parameters:
  • fs_relative_path (str) – FS relative path where to save instance segmentatino data.

  • annotator_data (str) – Annotator data.

_write_motion_vectors(fs_relative_path: str, annotator_data: Any) None#

Writes motion vectors data.

Parameters:
  • fs_relative_path (str) – FS relative path where to save motion vectors data.

  • annotator_data (str) – Annotator data.

_write_normals(fs_relative_path: str, annotator_data: Any) None#

Writes normals data.

Parameters:
  • fs_relative_path (str) – FS relative path where to save normals data.

  • annotator_data (str) – Annotator data.

_write_occlusion(fs_relative_path: str, annotator_data: Any) None#

Writes occlusion data.

Parameters:
  • fs_relative_path (str) – FS relative path where to save occlusion data.

  • annotator_data (str) – Annotator data.

_write_rgb(fs_relative_path: str, annotator_data: Any) None#

Writes RGB image data.

Parameters:
  • fs_relative_path (str) – FS relative path where to save RGB images.

  • annotator_data (str) – Annotator data.

_write_semantic_segmentation(fs_relative_path: str, annotator_data: Any) None#

Writes semantic segmentation data.

Parameters:
  • fs_relative_path (str) – FS relative path where to save semantic segmentatino data.

  • annotator_data (str) – Annotator data.

write(data: dict) None#

Write function called from the OgnWriter node on every frame to process annotator output.

Parameters:

data – A dictionary containing the annotator data for the current frame.