Contenuto principale

addAttribute

R2026b

Add attribute to label or sublabel in multi-sensor label definition creator

Since R2026b

Description

addAttribute(ldc,labelName,attributeName,typeOfAttribute,attributeDefault) adds an attribute with specified name and type to the indicated label or sublabel. The attribute is added under the hierarchy for the specified label or sublabel in the labelDefinitionCreatorMultiSensor object ldc.

addAttribute(___,Description="attributeDesc") specifies a string scalar or a character vector to describe the attribute using the Description name-value argument.

example

Examples

collapse all

Add attributes to a label and a sublabel in a labelDefinitionCreatorMultiSensor object and inspect the stored definitions.

Create an empty labelDefinitionCreatorMultiSensor object.

ldc = labelDefinitionCreatorMultiSensor;

Add a label with the name "Car". Specify the type of label as "Rectangle". Adding a "Rectangle" also adds a "Cuboid" entry to the label definitions table.

addLabel(ldc,"Car","Rectangle");

Add an attribute "Color" to the label "Car". Specify the attribute type as "String" with the value "Red".

addAttribute(ldc,"Car","Color","String","Red");

Add a label with the name "TrafficLight". Specify the type of the label as "Rectangle". Add a description to the label.

addLabel(ldc,"TrafficLight","Rectangle",Description="Bounding boxes for stop signs");

Add a sublabel with the name "RedLight" to the label "TrafficLight". Specify the type of the sublabel as "Rectangle".

addSublabel(ldc,"TrafficLight","RedLight","Rectangle");

Add an attribute "isOn" to the sublabel "RedLight" in the label "TrafficLight". Specify the attribute type for the sublabel as "logical" with the value false.

addAttribute(ldc,"TrafficLight/RedLight","isOn","logical",false);

Display the details of the updated labelDefinitionCreatorMultiSensor object.

ldc
ldc =
labelDefinitionCreatorMultiSensor contains the following labels:

	Car with 0 sublabels and 1 attributes and belongs to None group.	(info)
	TrafficLight with 1 sublabels and 0 attributes and belongs to None group.	(info)

For more details about attributes and sublabels, use the info method.

Display information about the attribute under the label "Car" using the object function info.

info(ldc,"Car")
           Name: "Car"
     SignalType: Image
      LabelType: Rectangle
          Group: "None"
     LabelColor: {''}
     Attributes: "Color"
      Sublabels: []
    Description: ' '

           Name: "Car"
     SignalType: PointCloud
      LabelType: Cuboid
          Group: "None"
     LabelColor: {''}
     Attributes: "Color"
      Sublabels: []
    Description: ' '

Display information about the sublabel "RedLight" in the label "TrafficLight" using the object function info.

info(ldc,"TrafficLight/RedLight")
           Name: "RedLight"
           Type: Rectangle
     LabelColor: ''
     Attributes: "isOn"
      Sublabels: []
    Description: ' '

Display information about the attribute "isOn" under the sublabel "RedLight" in the label "TrafficLight" using the object function info.

info(ldc,"TrafficLight/RedLight/isOn")
            Name: "isOn"
            Type: Logical
    DefaultValue: 0
     Description: ' '

Input Arguments

collapse all

Label definition creator for the multi-sensor workflow, specified as a labelDefinitionCreatorMultiSensor object.

Label or sublabel name, specified as a character vector or string scalar that uniquely identifies the label or sublabel to which the attribute is to be added.

  • To specify a label, use the form 'labelName'.

Example: addAttribute(ldc,"Car","Color")

  • To specify a sublabel, use the form 'labelName/sublabelName'. In this case, the attribute associates with the sublabel.

Example: addAttribute(ldc,"TrafficLight/RedLight","isOn")

Attribute name, specified as a character vector or string scalar that identifies the attribute to be added to the label or sublabel.

Type of attribute, specified as one of these values:

  • attributeType enumeration — The type of the attribute must be one of these attributeType (Computer Vision Toolbox) enumerators: Numeric, Logical, String, or List.

Example: addAttribute(ldc,"Car","Color",attributeType.String,"Red");

  • Character vector or string scalar — This value must partially or fully match one of the enumerators in the attributeType (Computer Vision Toolbox) enumeration.

Example: addAttribute(ldc,"Car","Color","Str","Red");

Default value of the attribute, specified as one of these:

  • Numeric scalar — Specify this value when typeOfAttribute is Numeric.

  • Logical scalar — Specify this value when typeOfAttribute is Logical.

  • Character vector or string scalar — Specify this value when typeOfAttribute is String.

  • Cell array of character vectors or cell array of string scalars — Specify this value when typeOfAttribute is List. The first entry in the cell array is the default value.

Version History

Introduced in R2026b