checkLabelDefinition

Validate label definition

The labeler app calls the checkLabelDefinition method for each ROI Label and Scene Label definition. The method restricts an automation algorithm to use only relevant labels. For example, a label definition of type Rectangle must not be used to mark a lane boundary.

Clients of AutomationAlgorithm must implement this method.

Syntax

isValid = checkLabelDefinition(algObj,labelDef)

Description

isValid = checkLabelDefinition(algObj,labelDef) returns true for valid label definitions and false for invalid definitions for the automation algorithm provided by algObj. labelDef is a struct containing label definitions. Definitions that return false are disabled during automation.

Examples

These examples show two ways of defining the checkLabelDefinition method for a client of an automation algorithm.

Restrict Automation to Rectangular ROI Labels

This checkLabelDefinition method designates Rectangle labels as valid, and all other labels as invalid.

function checkLabelDefinition(algObj,labelDef)

    if labelDef.Type == labelType.Rectangle
        isValid = true;
    else
        isValid = false;
    end
end

Restrict Automation to Any ROI

This checkLabelDefinition method designates ROI labels (Rectangle and Line) as valid, and all other labels as invalid.

function checkLabelDefinition(algObj,labelDef)

    if isROI(labelDef.Type)
        isValid = true;
    else
        isValid = false;
    end
end

Input Arguments

expand all

Automation algorithm, specified as a vision.labeler.AutomationAlgorithm object.

Label definition, specified as a struct containing Type and Name fields.

FieldDescription
TypeEnumeration of class labelType with possible values of Rectangle, Line, PixelLabel, and Scene.
Name Character vector containing the name of the specified label.

Example: Create a labelDef structure for a Rectangle label:

labelDef(1).Type = labelType.Rectangle;
labelDef(1).Name = 'Car';

Output Arguments

expand all

Flag to validate label definition, returned as true or false.

Tips

  • To access the selected label definitions (highlighted in yellow on the left panels titled ROI Label Definition and Scene Label Definition in the labeling app), use the SelectedLabelDefinitions property.

Introduced in R2017a