blenderproc.loader package¶
Module contents¶
-
blenderproc.loader.
get_random_world_background_hdr_img_path_from_haven
(data_path)¶ Sets the world background to a random .hdr file from the given directory.
Parameters: data_path ( str
) – A path pointing to a directory containing .hdr files.:return The path to a random selected path
Return type: str
-
blenderproc.loader.
load_AMASS
(data_path, sub_dataset_id, temp_dir=None, body_model_gender=None, subject_id='', sequence_id=-1, frame_id=-1, num_betas=10, num_dmpls=8)¶ use the pose parameters to generate the mesh and loads it to the scene.
Parameters: - data_path (
str
) – The path to the AMASS Dataset folder in resources folder. - sub_dataset_id (
str
) – Identifier for the sub dataset, the dataset which the human pose object should be extracted from. Available: [‘CMU’, ‘Transitions_mocap’, ‘MPI_Limits’, ‘SSM_synced’, ‘TotalCapture’, ‘Eyes_Japan_Dataset’, ‘MPI_mosh’, ‘MPI_HDM05’, ‘HumanEva’, ‘ACCAD’, ‘EKUT’, ‘SFU’, ‘KIT’, ‘H36M’, ‘TCD_handMocap’, ‘BML’] - temp_dir (
Optional
[str
]) – A temp directory which is used for writing the temporary .obj file. - body_model_gender (
Optional
[str
]) – The model gender, pose will represented using male, female or neutral body shape. Available:[male, female, neutral]. If None is selected a random one is choosen. - subject_id (
str
) – Type of motion from which the pose should be extracted, this is dataset dependent parameter. If left empty a random subject id is picked. - sequence_id (
int
) – Sequence id in the dataset, sequences are the motion recorded to represent certain action. If set to -1 a random sequence id is selected. - frame_id (
int
) – Frame id in a selected motion sequence. If none is selected a random one is picked - num_betas (
int
) – Number of body parameters - num_dmpls (
int
) – Number of DMPL parameters
Return type: Returns: The list of loaded mesh objects.
- data_path (
-
blenderproc.loader.
load_blend
(path, obj_types=None, name_regrex=None, data_blocks='objects', link=False)¶ Loads entities (everything that can be stored in a .blend file’s folders, see Blender’s documentation for bpy.types.ID for more info) that match a name pattern from a specified .blend file’s section/datablock.
Parameters: - path (
str
) – Path to a .blend file. - obj_types (
Union
[List
[str
],str
,None
]) – The type of objects to load. This parameter is only relevant when data_blocks is set to “objects”. Available options are: [‘mesh’, ‘curve’, ‘hair’, ‘armature’, ‘empty’, ‘light’, ‘camera’] - name_regrex (
Optional
[str
]) – Regular expression representing a name pattern of entities’ (everything that can be stored in a .blend file’s folders, see Blender’s documentation for bpy.types.ID for more info) names. - data_blocks (
Union
[List
[str
],str
]) – The datablock or a list of datablocks which should be loaded from the given .blend file. Available options are: [‘armatures’, ‘cameras’, ‘curves’, ‘hairs’, ‘images’, ‘lights’, ‘materials’, ‘meshes’, ‘objects’, ‘textures’] - link (
bool
) – whether to link instead of a append datablocs from .blend file. Linked objects can not be modifed.
Return type: Returns: The list of loaded mesh objects.
- path (
-
blenderproc.loader.
load_bop_intrinsics
(bop_dataset_path, split='test', cam_type='')¶ Load and set the camera matrix and image resolution of a specified BOP dataset
Parameters: Return type: Returns: camera matrix K, W, H
-
blenderproc.loader.
load_bop_objs
(bop_dataset_path, model_type='', obj_ids=[], sample_objects=False, num_of_objs_to_sample=None, obj_instances_limit=-1, mm2m=False, move_origin_to_x_y_plane=False, temp_dir=None)¶ Loads all or a subset of 3D models of any BOP dataset
Parameters: - bop_dataset_path (
str
) – Full path to a specific bop dataset e.g. /home/user/bop/tless. - model_type (
str
) – Optionally, specify type of BOP model. Available: [reconst, cad or eval]. - obj_ids (
list
) – List of object ids to load. Default: [] (load all objects from the given BOP dataset) - sample_objects (
bool
) – Toggles object sampling from the specified dataset. - num_of_objs_to_sample (
Optional
[int
]) – Amount of objects to sample from the specified dataset. If this amount is bigger than the dataset actually contains, then all objects will be loaded. - obj_instances_limit (
int
) – Limits the amount of object copies when sampling. Default: -1 (no limit). - mm2m (
bool
) – Specify whether to convert poses and models to meters. - move_origin_to_x_y_plane (
bool
) – Move center of the object to the lower side of the object, this will not work when used in combination with pose estimation tasks! This is designed for the use-case where BOP objects are used as filler objects in the background. - temp_dir (
Optional
[str
]) – A temp directory which is used for writing the temporary .ply file.
Return type: Returns: The list of loaded mesh objects.
- bop_dataset_path (
-
blenderproc.loader.
load_bop_scene
(bop_dataset_path, scene_id, model_type='', cam_type='', split='test', source_frame=['X', '-Y', '-Z'], mm2m=False, temp_dir=None)¶ Replicate a BOP scene from the given dataset: load scene objects, object poses, camera intrinsics and extrinsics
- Interfaces with the bob_toolkit, allows loading of train, val and test splits
- Relative camera poses are loaded/computed with respect to a reference model
- Sets real camera intrinsics
Parameters: - bop_dataset_path (
str
) – Full path to a specific bop dataset e.g. /home/user/bop/tless. - scene_id (
int
) – Specify BOP dataset scene to synthetically replicate. Default: -1 (no scene is replicated, only BOP Objects are loaded). - model_type (
str
) – Optionally, specify type of BOP model. Available: [reconst, cad or eval]. - cam_type (
str
) – Camera type. If not defined, dataset-specific default camera type is used. - split (
str
) – Optionally, test or val split depending on BOP dataset. - source_frame (
list
) – Can be used if the given positions and rotations are specified in frames different from the blender frame. Has to be a list of three strings. Example: [‘X’, ‘-Z’, ‘Y’]: Point (1,2,3) will be transformed to (1, -3, 2). Available: [‘X’, ‘Y’, ‘Z’, ‘-X’, ‘-Y’, ‘-Z’]. - mm2m (
bool
) – Specify whether to convert poses and models to meters. - temp_dir (
Optional
[str
]) – A temp directory which is used for writing the temporary .ply file.
Return type: Returns: The list of loaded mesh objects.
-
blenderproc.loader.
load_ccmaterials
(folder_path='resources/cctextures', used_assets=None, preload=False, fill_used_empty_materials=False, add_custom_properties=None, use_all_materials=False)¶ This method loads all textures obtained from https://cc0textures.com, use the script (scripts/download_cc_textures.py) to download all the textures to your pc.
All textures here support Physically based rendering (PBR), which makes the textures more realistic.
All materials will have the custom property “is_cc_texture”: True, which will make the selection later on easier.
Parameters: - folder_path (
str
) – The path to the downloaded cc0textures. - used_assets (
Optional
[list
]) – A list of all asset names, you want to use. The asset-name must not be typed in completely, only the beginning the name starts with. By default all assets will be loaded, specified by an empty list. - preload (
bool
) – If set true, only the material names are loaded and not the complete material. - fill_used_empty_materials (
bool
) – If set true, the preloaded materials, which are used are now loaded completely. - add_custom_properties (
Optional
[dict
]) – A dictionary of materials and the respective properties. - use_all_materials (
bool
) – If this is false only a selection of probably useful textures is used. This excludes some see through texture and non tileable texture.
- :return a list of all loaded materials, if preload is active these materials do not contain any textures yet
- and have to be filled before rendering (by calling this function again, no need to save the prior returned list)
Return type: List
[Material
]- folder_path (
-
blenderproc.loader.
load_front3d
(json_path, future_model_path, front_3D_texture_path, label_mapping, ceiling_light_strength=0.8, lamp_light_strength=7.0)¶ Loads the 3D-Front scene specified by the given json file.
Parameters: - json_path (
str
) – Path to the json file, where the house information is stored. - future_model_path (
str
) – Path to the models used in the 3D-Front dataset. - front_3D_texture_path (
str
) – Path to the 3D-FRONT-texture folder. - label_mapping (
LabelIdMapping
) – A dict which maps the names of the objects to ids. - ceiling_light_strength (
float
) – Strength of the emission shader used in the ceiling. - lamp_light_strength (
float
) – Strength of the emission shader used in each lamp.
Return type: Returns: The list of loaded mesh objects.
- json_path (
-
blenderproc.loader.
load_haven_mat
(folder_path='resources/haven', used_assets=None, preload=False, fill_used_empty_materials=False, add_cp=None, return_random_element=False)¶ Loads all specified haven textures from the given directory.
Parameters: - folder_path (
Union
[str
,Path
]) – The path to the downloaded haven. - used_assets (
Optional
[List
[str
]]) – A list of all asset names, you want to use. The asset-name must not be typed in completely, only the beginning the name starts with. By default all assets will be loaded, specified by an empty list or None. - preload (
bool
) – If set true, only the material names are loaded and not the complete material. - fill_used_empty_materials (
bool
) – If set true, the preloaded materials, which are used are now loaded completely. - add_cp (
Optional
[Dict
[str
,Any
]]) – A dictionary of materials and the respective properties. - return_random_element (
bool
) – If this is True only a single Material is loaded and returned, if you want to sample many materials load them all with the preload option, use them and then fill the used empty materials instead of calling this function multiple times.
- :return a list of all loaded materials, if preload is active these materials do not contain any textures yet
- and have to be filled before rendering (by calling this function again, there is no need to save the prior returned list) or if return_random_element is True only a single Material is returned
Return type: Union
[List
[Material
],Material
]- folder_path (
-
blenderproc.loader.
load_ikea
(data_dir='resources/IKEA', obj_categories=None, obj_style=None)¶ Loads ikea objects based on selected type and style.
If there are multiple options it picks one randomly or if style or type is None it picks one randomly.
Parameters: - data_dir (
str
) – The directory with all the IKEA models. - obj_categories (
Union
[list
,str
,None
]) – The category to use for example: ‘bookcase’. This can also be a list of elements. Available: [‘bed’, ‘bookcase’, ‘chair’, ‘desk’, ‘sofa’, ‘table’, ‘wardrobe’] - obj_style (
Optional
[str
]) – The IKEA style to use for example: ‘hemnes’. See data_dir for other options.
Return type: Returns: The list of loaded mesh objects.
- data_dir (
-
blenderproc.loader.
load_obj
(filepath, cached_objects=None, **kwargs)¶ Import all objects for the given file and returns the loaded objects
In .obj files a list of objects can be saved in. In .ply files only one object can saved so the list has always at most one element
Parameters: - filepath (
str
) – the filepath to the location where the data is stored - cached_objects (
Optional
[Dict
[str
,List
[MeshObject
]]]) – a dict of filepath to objects, which have been loaded before, to avoid reloading (the dict is updated in this function) - kwargs – all other params are handed directly to the bpy loading fct. check the corresponding documentation
Return type: Returns: The list of loaded mesh objects.
- filepath (
-
blenderproc.loader.
load_pix3d
(used_category, data_path='resources/pix3d')¶ Loads one random Pix3D object from the given category.
Parameters: Return type: Returns: The list of loaded mesh objects.
-
blenderproc.loader.
load_replica
(data_path, data_set_name, use_smooth_shading=False)¶ Just imports the configured .ply file straight into blender for the replica case.
Parameters: Return type: Returns: The list of loaded mesh objects.
-
blenderproc.loader.
load_replica_segmented_mesh
(data_path, data_set_name, use_smooth_shading=False)¶ Loads a segmented replica file
Parameters: Return type: Returns: The list of loaded and separated mesh objects.
-
blenderproc.loader.
load_scenenet
(file_path, texture_folder, label_mapping, unknown_texture_folder=None)¶ Loads all SceneNet objects at the given “file_path”.
The textures for each object are sampled based on the name of the object, if the name is not represented in the texture folder the unknown folder is used. This folder does not exists, after downloading the texture dataset. Make sure to create and put some textures, you want to use for these instances there.
All objects get “category_id” set based on the data in the “resources/id_mappings/nyu_idset.csv”
Each object will have the custom property “is_scene_net_obj”.
Parameters: - file_path (
str
) – The path to the .obj file from SceneNet. - texture_folder (
str
) – The path to the texture folder used to sample the textures. - unknown_texture_folder (
Optional
[str
]) – The path to the textures, which are used if the the texture type is unknown. The default path does not exist if the dataset was just downloaded, it has to be created manually.
Return type: Returns: The list of loaded mesh objects.
- file_path (
-
blenderproc.loader.
load_shapenet
(data_path, used_synset_id, used_source_id='', move_object_origin=True)¶ This loads an object from ShapeNet based on the given synset_id, which specifies the category of objects to use.
From these objects one is randomly sampled and loaded.
Todo: not good: Note: if this module is used with another loader that loads objects with semantic mapping, make sure the other module is loaded first in the config file.
Parameters: - data_path (
str
) – The path to the ShapeNetCore.v2 folder. - used_synset_id (
str
) – The synset id for example: ‘02691156’, check the data_path folder for more ids. - used_source_id (
str
) – Object identifier of the a particular ShapeNet category, see inside any ShapeNet category for identifiers - move_object_origin (
bool
) – Moves the object center to the bottom of the bounding box in Z direction and also in the middle of the X and Y plane, this does not change the .location of the object. Default: True
Return type: Returns: The loaded mesh object.
- data_path (
-
blenderproc.loader.
load_suncg
(house_path, label_mapping, suncg_dir=None)¶ 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: Return type: Returns: The list of loaded mesh objects.
-
blenderproc.loader.
load_texture
(path, colorspace='sRGB')¶ Loads images and creates image textures.
Depending on the form of the provided path: 1. Loads an image, creates an image texture, and assigns the loaded image to the texture, when a path to an image is provided. 2. Loads images and for each creates a texture, and assing an image to this texture, if a path to a folder with images is provided.
NOTE: Same image file can be loaded once to avoid unnecessary overhead. If you really need the same image in different colorspaces, then have a copy per desired colorspace and load them in different instances of this Loader.
Parameters: Return type: List
[Texture
]Returns: The list of created textures.
-
blenderproc.loader.
load_urdf
(urdf_file, weight_distribution='rigid', fk_offset=[0.0, -1.0, 0.0], ik_offset=[0.0, 1.0, 0.0])¶ Loads an urdf object from an URDF file.
Parameters: - urdf_file (
str
) – Path to the URDF file. - weight_distribution (
str
) – One of [‘envelope’, ‘automatic’, ‘rigid’]. For more information please see https://docs.blender.org/manual/en/latest/animation/armatures/skinning/parenting.html. - fk_offset (
Union
[List
[float
],Vector
, <built-in function array>]) – Offset between fk (forward kinematic) bone chain and link bone chain. This does not have any effect on the transformations, but can be useful for visualization in blender. - ik_offset (
Union
[List
[float
],Vector
, <built-in function array>]) – Offset between ik (inverse kinematic) bone chain and link bone chain. Effects on the transformation (e.g. urdf_object.set_location_ik()) are being handled internally. Useful for visualization in blender.
Return type: Returns: URDF object instance.
- urdf_file (