Segmentation

The segmentation camera returns image representations of ground truth segmentation of the scene. At the startup, AirGen assigns value 0 to 255 to each mesh available in the environment. This value is then mapped to a specific color in a predefined color palette. Given which meshes are visible from the camera, the camera returns an image containing the masks with the corresponding colors.

Assigning segmentation IDs

By default, AirGen assigns a unique ID to each mesh in the environment. However, you can assign your own IDs to the meshes using the simSetSegmentationObjectID method. This method takes the mesh name and the ID as arguments. The following code snippet demonstrates how to assign a custom ID to a mesh:

simSetSegmentationObjectID("chair0", 20, True)

Environments often contain many meshes that are of the same object type. For example, a room may contain many chairs, and a factory may contain many machines. In such cases, it is useful to assign the same ID to all the meshes of the same type. AirGen supports regex based ID assignment. The following code snippet demonstrates how to assign the same ID to all the meshes of the same type:

simSetSegmentationObjectID("chair[\w]*", 20, True)

An object's ID can be set to -1 to make it not show up on the segmentation image.