addAttribute
Add attributes to label or sublabel in label definition creator object
Syntax
Description
addAttribute(
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
,labelName
,attributeName
,typeOfAttribute
,attributeDefault
)ldc
.
addAttribute(___,
specifies options using one or more name-value arguments in addition to the input arguments
in the previous syntax.Name,Value
)
Examples
Add Attributes to Label and Sublabel in Label Definition Creator Object
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
ldc
— Label definition creator
labelDefinitionCreator
object
Label definition creator, specified as a labelDefinitionCreator
object.
labelName
— Label or sublabel name
character vector | string scalar
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.
attributeName
— Attribute name
character vector | string scalar
Attribute name, specified as a character vector or string scalar that identifies the attribute to be added to the label or sublabel.
typeOfAttribute
— Type of attribute
attributeType
enumeration | character vector | string scalar
Type of attribute, specified as one of these values:
attributeType
enumeration — The type of attribute must be one of these enumerators inattributeType
enumeration:Numeric
,Logical
,String
, orList
.
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');
attributeDefault
— Default value of attribute
numeric scalar | logical scalar | character vector | string scalar | cell array of character vectors | cell array of string scalars
Default value of the attribute, specified as one of these values:
Numeric scalar — Specify this value when
typeOfAttribute
isNumeric
.Logical scalar — Specify this value when
typeOfAttribute
isLogical
.Character vector or string scalar — Specify this value when
typeOfAttribute
isString
.Cell array of character vectors or cell array of string scalars — Specify this value when
typeOfAttribute
isList
.
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');
Description
— Attribute description
' '
(default) | character vector | string scalar
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
See Also
Objects
Functions
Comando MATLAB
Hai fatto clic su un collegamento che corrisponde a questo comando MATLAB:
Esegui il comando inserendolo nella finestra di comando MATLAB. I browser web non supportano i comandi MATLAB.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)