blenderproc.python.modules.provider.getter.AttributeMerger module

class blenderproc.python.modules.provider.getter.AttributeMerger.AttributeMerger(config)[source]

Bases: blenderproc.python.modules.main.Provider.Provider

Similarly to getter.Attribute Provider, getter.AttributeMerger returns the result of processing of the list of values, but the list is comprised of the return values of invoked providers. All return values in the list must comply with the requirements. See tables below for more info.

Example 1: Get a mathutils.Vector which represents an average vector of two Uniform3d sampler return values

{
  "provider": "getter.AttributeMerger",
  "elements": [
  {
    "provider": "sampler.Uniform3d",
    "min": [0, 0, 0],
    "max": [1, 1, 1]
  },
  {
    "provider": "sampler.Uniform3d",
    "min": [2, 2, 2],
    "max": [3, 3, 3]
  }
  ],
  "transform_by": "avg"
}

Example 2: Get a value which is a sum of a point sampled by sampler.Uniform3d, of an average location of all objects with names matching the pattern, and of a constant location.

{
  "provider": "getter.AttributeMerger",
  "elements": [
  {
    "provider": "sampler.Uniform3d",
    "min": [0, 0, 0],
    "max": [1, 1, 1]
  },
  {
    "provider": "getter.Attribute",
    "entities": {
      "provider": "getter.Entity",
      "conditions": {
        "name": "Icosphere.*"
      }
    },
  "get": "location",
  "transform_by": "avg"
  },
    [1, 2, 3]
  ],
  "transform_by": "sum"
}

Configuration:

Parameter Description Type
elements List of user-configured Provider calls. list
transform_by Name of the operation to perform on the list of Provider return values. See table below for supported operation names. string

Operations:

Parameter Description Type
sum Returns the sum of all values of the input list. (return). float
avg Returns the average value of all values of the input list. (return). float
_avg(raw_result)[source]

Sums up the values of the list and divides the sum by the amount of items in the list.

Returns:The average value of all values of the input list.
static _check_compatibility(raw_result)[source]

Checks if the list of values contains appropriate data of int/float, or mathutils.Vector type.

Parameters:raw_result – list of provider output values. Type: List
Returns:True if list is of of int (and/or) float, or mathutils.Vector data type. False if not. Type: bool.
_sum(raw_result)[source]

Sums up the values of the list.

Returns:The sum of all values of the input list.
run()[source]

Returns the result of processing of the list of values.