blenderproc.python.loader.SuncgLoader module

Load the SUNCG dataset, beware that the SUNCG dataset can not be downloaded anymore.

class blenderproc.python.loader.SuncgLoader._SuncgLoader[source]

Bases: object

static adjust_material_nodes(mat, adjustments)[source]

Adjust the material node of the given material according to the given adjustments.

Textures or diffuse colors will be changed according to the given material_adjustments.

Parameters:
  • mat (Material) – The blender material.

  • adjustments (Dict[str, str]) – A dict containing a new “diffuse” color or a new “texture” path

collection_of_loaded_mats: Dict[str, Dict[str, Material]] = {}
collection_of_loaded_objs: Dict[str, List[MeshObject]] = {}
static correct_bbox_frame(bbox)[source]

Corrects the coordinate frame of the given bbox.

Parameters:

bbox (Dict[str, Union[ndarray, list, Vector]]) – The bbox.

Return type:

Dict[str, ndarray]

Returns:

The corrected bbox.

static get_type_and_value_from_mat(mat)[source]

Returns the type of the material -> either diffuse or with texture (there are only two in SUNCG)

Parameters:

mat (Material) – the material where the type and value should be determined

Return type:

Tuple[str, str]

Returns:

mat_type, value: mat_type is either “diffuse” or “texture”, the value contains either name of the image or the color mapped to an RGB string of the values

static load_box(node, material_adjustments, transform, parent, label_mapping)[source]

Creates a cube inside blender which follows the specifications of the given node.

Parameters:
  • node (Dict[str, Any]) – The node dict which contains information from house.json..

  • material_adjustments (List[Dict[str, str]]) – Adjustments to the materials which were specified inside house.json.

  • transform (Matrix) – The transformation that should be applied to the loaded objects.

  • parent (Entity) – The parent object to which the ground should be linked

Return type:

List[MeshObject]

Returns:

The list of loaded mesh objects.

static load_ground(node, metadata, material_adjustments, transform, house_id, parent, label_mapping)[source]

Load the ground specified in the given node.

Parameters:
  • node (Dict[str, Any]) – The node dict which contains information from house.json..

  • metadata (Dict[str, Union[str, int]]) – A dict of metadata which will be written into the object’s custom data.

  • material_adjustments (List[Dict[str, str]]) – Adjustments to the materials which were specified inside house.json.

  • transform (Matrix) – The transformation that should be applied to the loaded objects.

  • house_id (str) – The id of the current house.

  • parent (Entity) – The parent object to which the ground should be linked

Return type:

List[MeshObject]

Returns:

The list of loaded mesh objects.

static load_obj(path, metadata, material_adjustments, transform=None, parent=None)[source]

Load the wavefront object file from the given path and adjust according to the given arguments.

Parameters:
  • path (str) – The path to the .obj file.

  • metadata (Dict[str, Union[str, int]]) – A dict of metadata which will be written into the object’s custom data.

  • material_adjustments (List[Dict[str, str]]) – Adjustments to the materials which were specified inside house.json.

  • transform (Optional[Matrix]) – The transformation that should be applied to the loaded objects.

  • parent (Optional[Entity]) – The parent object to which the object should be linked

Return type:

List[MeshObject]

Returns:

The list of loaded mesh objects.

static load_object(node, metadata, material_adjustments, transform, parent)[source]

Load the object specified in the given node.

Parameters:
  • node (Dict[str, Any]) – The node dict which contains information from house.json..

  • metadata (Dict[str, Union[str, int]]) – A dict of metadata which will be written into the object’s custom data.

  • material_adjustments (List[Dict[str, str]]) – Adjustments to the materials which were specified inside house.json.

  • transform (Matrix) – The transformation that should be applied to the loaded objects.

  • parent (Entity) – The parent object to which the ground should be linked

Return type:

List[MeshObject]

Returns:

The list of loaded mesh objects.

static load_room(node, metadata, material_adjustments, transform, house_id, parent, room_per_object, label_mapping)[source]

Load the room specified in the given node.

Parameters:
  • node (Dict[str, Any]) – The node dict which contains information from house.json..

  • metadata (Dict[str, Union[str, int]]) – A dict of metadata which will be written into the object’s custom data.

  • material_adjustments (List[Dict[str, str]]) – Adjustments to the materials which were specified inside house.json.

  • transform (Matrix) – The transformation that should be applied to the loaded objects.

  • house_id (str) – The id of the current house.

  • parent (Entity) – The parent object to which the room should be linked

  • room_per_object (Dict[int, Entity]) – A dict for object -> room lookup (Will be written into)

Return type:

List[Union[Entity, MeshObject]]

Returns:

The list of loaded mesh objects.

static read_model_category_mapping(path)[source]

Reads in the model category mapping csv.

Parameters:

path (str) – The path to the csv file.

static recreate_material_nodes(mat, force_texture)[source]

Remove all nodes and recreate a diffuse node, optionally with texture.

This will replace all material nodes with only a diffuse and a texturing node (to speedup rendering).

Parameters:
  • mat (Material) – The blender material

  • force_texture (bool) – True, if a texture node should always be created even if the material has no texture at the moment

static rename_materials()[source]

Rename all materials based on their texture if they have one

This makes the accessing later on easier

suncg_dir: Optional[str] = None
static transform_and_colorize_object(obj, material_adjustments, transform=None, parent=None)[source]

Applies the given transformation to the object and refactors its materials.

Material is replaced with an existing material if possible or is changed according to the material_adjustments

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

  • material_adjustments (List[Dict[str, str]]) – A list of adjustments to make. (Each element i corresponds to material_i)

  • transform (Optional[Matrix]) – The transformation matrix to apply

  • parent (Optional[Entity]) – The parent object to which the object should be linked

blenderproc.python.loader.SuncgLoader.load_suncg(house_path, label_mapping, suncg_dir=None)[source]

Loads a house.json file into blender.

  • Loads all objects files specified in the house.json file.

  • Orders them hierarchically (level -> room -> object)

  • Writes metadata into the custom properties of each object

Parameters:
  • house_path (str) – The path to the house.json file which should be loaded.

  • label_mapping (LabelIdMapping) – A dict which maps the names of the objects to ids.

  • suncg_dir (Optional[str]) – The path to the suncg root directory which should be used for loading objects, rooms, textures etc.

Return type:

List[Union[Entity, MeshObject]]

Returns:

The list of loaded mesh objects.