blenderproc.python.renderer.SegMapRendererUtility module

Provides functionality to render a segmentation image.

blenderproc.python.renderer.SegMapRendererUtility._colorize_object(obj, color, use_alpha_channel)[source]

Adjusts the materials of the given object, s.t. they are ready for rendering the seg map.

This is done by replacing all nodes just with an emission node, which emits the color corresponding to the category of the object.

Parameters:
  • obj (Object) – The object to use.

  • color (Vector) – RGB array of a color in the range of [0, self.render_colorspace_size_per_dimension].

  • use_alpha_channel (bool) – If true, the alpha channel stored in .png textures is used.

blenderproc.python.renderer.SegMapRendererUtility._colorize_objects_for_instance_segmentation(objects, use_alpha_channel, render_colorspace_size_per_dimension)[source]

Sets a different color to each object.

Parameters:
  • objects (List[Object]) – A list of objects.

  • use_alpha_channel (bool) – If true, the alpha channel stored in .png textures is used.

  • render_colorspace_size_per_dimension (int) – The limit of the colorspace to use per dimension for generating colors.

Return type:

Tuple[List[List[int]], int, List[Object]]

Returns:

The num_splits_per_dimension of the spanned color space, the color map

blenderproc.python.renderer.SegMapRendererUtility._set_world_background_color(color)[source]

Set the background color of the blender world object.

Parameters:

color (List[float]) – A 3-dim list containing the background color.

blenderproc.python.renderer.SegMapRendererUtility.render_segmap(output_dir=None, temp_dir=None, map_by='class', default_values=None, file_prefix='segmap_', output_key='segmap', segcolormap_output_file_prefix='instance_attribute_map_', segcolormap_output_key='segcolormap', use_alpha_channel=False, render_colorspace_size_per_dimension=2048)[source]

Renders segmentation maps for all frames

Parameters:
  • output_dir (Optional[str]) – The directory to write images to.

  • temp_dir (Optional[str]) – The directory to write intermediate data to.

  • map_by (Union[str, List[str]]) – The attributes to be used for color mapping.

  • default_values (Optional[Dict[str, int]]) – The default values used for the keys used in attributes, if None is {“class”: 0}.

  • file_prefix (str) – The prefix to use for writing the images.

  • output_key (str) – The key to use for registering the output.

  • segcolormap_output_file_prefix (str) – The prefix to use for writing the segmentation-color map csv.

  • segcolormap_output_key (str) – The key to use for registering the segmentation-color map output.

  • use_alpha_channel (bool) – If true, the alpha channel stored in .png textures is used.

  • render_colorspace_size_per_dimension (int) – As we use float16 for storing the rendering, the interval of integers which can be precisely stored is [-2048, 2048]. As blender does not allow negative values for colors, we use [0, 2048] ** 3 as our color space which allows ~8 billion different colors/objects. This should be enough.

Return type:

Dict[str, Union[ndarray, List[ndarray]]]

Returns:

dict of lists of segmaps and (for instance segmentation) segcolormaps