Create Automation Algorithm for Labeling
The Image Labeler, Video Labeler, Lidar Labeler (Lidar Toolbox), and Ground Truth Labeler (Automated Driving Toolbox) apps enable you to label ground truth for a variety of data sources. You can use an automation algorithm to automatically label your data by creating and importing a custom automation algorithm.
Create New Algorithm
vision.labeler.AutomationAlgorithm class enables you to define a custom
label automation algorithm for use in the labeling apps. You can use the class to define
the interface used by the app to run an automation algorithm.
To define and use a custom automation algorithm, you must first define a class for your algorithm and save it to the appropriate folder.
Create Automation Folder
within a folder that is on the MATLAB® path. For example, if the folder
is on the MATLAB path, then create the
projectFolder = fullfile('local','MyProject'); automationFolder = fullfile('+vision','+labeler'); mkdir(projectFolder,automationFolder)
Define Class That Inherits from
At the MATLAB command prompt, enter the appropriate command to open the labeling app:
Then, load a data source, create at least one label definition, and
on the app toolstrip, select Select Algorithm > Add Algorithm > Create New Algorithm. In the
class template that opens, define your custom automation algorithm. Follow the
instructions in the header and comments in the class.
If the algorithm is
time-dependent, that is, has a dependence on the
timestamp of execution, your custom automation algorithm must also inherit from the
vision.labeler.mixin.Temporal class. For more details on implementing
time-dependent, or temporal, algorithms, see Temporal Automation Algorithms.
If the algorithm is blocked
image based, your custom automation algorithm must also inherit from
vision.labeler.mixin.BlockedImageAutomation class. For more details on
implementing blocked image algorithms, see Blocked Image Automation Algorithms.
Save Class File to Automation Folder
To use your custom algorithm from within the
labeling app, save the file to the
+vision/+labeler folder that
you created. Make sure that this folder is on the MATLAB search path. To add a folder to the path, use the
Refresh Algorithm List in Labeling App
To start using your custom algorithm, refresh the algorithm list so that the algorithm displays in the app. On the app toolstrip, select Select Algorithm > Refresh list.
Import Existing Algorithm
To import an existing custom algorithm into a labeling app, on the app toolstrip, select Select Algorithm > Add Algorithm > Import Algorithm and then refresh the list.
Custom Algorithm Execution
When you run an automation session in a labeling app, the properties and methods in your automation algorithm class control the behavior of the app.
Check Label Definitions
When you click Automate, the
app checks each label definition in the ROI Labels and
Scene Labels panes by using the
checkLabelDefinition method defined
in your custom algorithm. Label definitions that return
retained for automation. Label definitions that return
disabled and not included. Use this method to choose a subset of label definitions
that are valid for your custom algorithm. For example, if your custom algorithm is a
semantic segmentation algorithm, use this method to return
for label definitions that are not of type
After you select the algorithm, click
Automate to start an automation session. Then, click
Settings, which enables you to modify custom app settings.
To control the Settings options, use the
Control Algorithm Execution
When you open an automation algorithm session in the app and then click
Run, the app calls the
to check if it is ready for execution. If the method returns
false, the app does not execute the automation algorithm. If
the method returns
true, the app calls the
initialize method and then the
run method on
every frame selected for automation. Then, at the end of the automation run, the app
The diagram shows this flow of execution for the labeling apps.
checkSetupmethod to check whether all conditions needed for your custom algorithm are set up correctly. For example, before running the algorithm, check that the scene contains at least one ROI label.
initializemethod to initialize the state for your custom algorithm by using the frame.
runmethod to implement the core of the algorithm that computes and returns labels for each frame.
terminatemethod to clean up or terminate the state of the automation algorithm after the algorithm runs.
- Video Labeler | Image Labeler | Ground Truth Labeler (Automated Driving Toolbox) | Lidar Labeler (Lidar Toolbox)
- Automate Ground Truth Labeling of Lane Boundaries (Automated Driving Toolbox)
- Automate Ground Truth Labeling for Semantic Segmentation (Automated Driving Toolbox)
- Automate Attributes of Labeled Objects (Automated Driving Toolbox)