Main Content

addAttribute

Add attributes to label or sublabel in label definition creator object

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 label definition creator object ldc.

example

addAttribute(___,Name,Value) specifies options using one or more name-value arguments in addition to the input arguments in the previous syntax.

Examples

collapse all

Load an existing label definitions table into the workspace.

load('sublabelDefsTable.mat')

Create a label definition creator object from the label definitions table.

ldc = labelDefinitionCreator(labelDefs)
ldc = 
labelDefinitionCreator contains the following labels:

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

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

Add attribute "Color" to the label "Car". Specify the attribute type as a string with value 'Red'.

addAttribute(ldc,'Car','Color',attributeType.String,'Red')

Display information about the sublabels under the label "TrafficLight".

info(ldc,'TrafficLight')
           Name: "TrafficLight"
           Type: Rectangle
     LabelColor: {''}
          Group: "None"
     Attributes: []
      Sublabels: ["RedLight"    "GreenLight"]
    Description: 'Bounding boxes for traffic light'

Add attribute "IsOn" to the label "TrafficLight/RedLight". Specify the attribute type as logical with value true.

addAttribute(ldc,'TrafficLight/RedLight','IsOn','logical',true)

Display the details of the label definition creator object.

ldc
ldc = 
labelDefinitionCreator contains the following labels:

	Car with 1 sublabels and 1 attributes and belongs to None group.	(info)
	TrafficLight with 2 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 attributes under the label "Car" using the info object function.

info(ldc,'Car')
           Name: "Car"
           Type: Rectangle
     LabelColor: {''}
          Group: "None"
     Attributes: "Color"
      Sublabels: "Light"
    Description: 'Bounding box for vehicle'

Display information about the attributes for sublabel "RedLight" under the label "TrafficLight" using the info object function.

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

Input Arguments

collapse all

Label definition creator, specified as a labelDefinitionCreator 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'.

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

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 attribute must be one of these enumerators in attributeType enumeration: 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 attributeType enumeration.

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

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

  • 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.

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: addAttribute(ldc,'Car/Wheel','Outsidediameter',attributeType.Numeric,740,'Description','Outside diameter in mm');

Attribute description, specified as a comma-separated pair consisting of 'Description' and a character vector or string scalar. Use this name-value pair to describe the attribute.

Version History

Introduced in R2018b