blenderproc.python.modules.utility.ItemCollection module

class blenderproc.python.modules.utility.ItemCollection.ItemCollection(add_item_func, default_item_parameters)[source]

Bases: object

Manages the reading and creation of multiple items (like light sources or cam poses) from config or file.

_collect_arguments_from_file(path, file_format, number_of_arguments)[source]

Reads in all lines of the given file and returns them as a list of lists of arguments

This method also checks is the lines match the configured file format.

Parameters:
  • path – The path of the file.
  • file_format – Specifies how the arguments should be mapped to parameters.
  • number_of_arguments – The total number of arguments required per line.
Returns:

A list of lists of arguments

_length_of_parameter(parameter_name, number_of_arguments_per_parameter)[source]

Returns how many arguments the given parameter expects.

Parameters:
  • parameter_name – The name of the parameter.
  • number_of_arguments_per_parameter – Dict where {key:value} pairs are {name of the parameter:expected number of arguments} pairs.
Returns:

The expected number of arguments

_parse_arguments_from_file(arguments, file_format, number_of_arguments_per_parameter)[source]

Sets the parameters using the given arguments.

Parameters:
  • arguments – A list of arguments read in from the file.
  • file_format – Specifies how the arguments should be mapped to parameters.
  • number_of_arguments_per_parameter – A dicts which maps parameter names to their required number of arguments.
Returns:

A dict containing the parameters specified by the given arguments.

_set_parameter_value(data, parameter_name_parts, value)[source]

Sets the parameter inside the given nested dict

({}, [“rotation”,”value”], 42) will result in:

{
  "rotation": {
    "value": 42
  }
}
Parameters:
  • data – The dict into which the parameter value should be written.
  • parameter_name_parts – A list of strings which will be used as keys when creating the nested dicts and setting the value.
  • value – The value to set
add_item(parameters)[source]

Adds a new item based on the given parameters.

Parameters:parameters – A dict specifying the parameters.
add_items_from_dicts(dicts)[source]

Adds items from a list of dicts.

Every dict specifies the parameters of one new item.

Parameters:dicts – The list of dicts.
add_items_from_file(path, file_format, number_of_arguments_per_parameter)[source]

Adds one item per line of the given file.

Parameters:
  • path – The path of the file to read.
  • file_format – Specifies how each line is formatted
  • number_of_arguments_per_parameter – A dict specifying the length of parameters that require more than one argument.