Main Content

Create Automation Algorithm for Labeling

The Lidar Labeler app enables you to label ground truth for a variety of data sources. You can automate the labeling process by creating and importing a custom automation algorithm into the app.

Create New Algorithm

At the MATLAB® command prompt, enter the command: lidarLabeler to open the Lidar Labeler app. Then, load a data source and create at least one label definition.

Define Class That Inherits from AutomationAlgorithm Class

On the LABEL tab of the app toolstrip, in the Automate Labeling section, click Select Algorithm > Add Algorithm > Create New Algorithm. The app opens a lidar.labeler.AutomationAlgorithm class that enables you to define a custom automation algorithm. You can also use this class to define a user-interface within the app to run the algorithm.

If the algorithm is time-dependent, that is, when it has a dependence on the timestamp of execution, your custom automation algorithm must also inherit from the lidar.labeler.mixin.Temporal class. For more details on implementing time-dependent, or temporal, algorithms, see Temporal Automation Algorithms.

To use an automation algorithm in the Lidar Labeler app, you must define it using the lidar.labeler.AutomationAlgorithm class and save it in an appropriate folder.

Create Automation Folder

Create a +lidar/+labeler/ folder within a folder that is on the MATLAB path. For example, if the folder /local/MyProject is on the MATLAB path, then create the +lidar/+labeler/ folder hierarchy as follows:

projectFolder = fullfile('local','MyProject');
automationFolder = fullfile('+lidar','+labeler');
mkdir(projectFolder,automationFolder)
The resulting folder is located at /local/MyProject/+lidar/+labeler.

Save Class File to Automation Folder

To use your custom algorithm from within the labeling app, save the file to the +lidar/+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 addpath function.

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 true are retained for automation. Label definitions that return false are 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 false for label definitions that are not of type Voxel.

Control Settings

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 settingsDialog method.

Control Algorithm Execution

When you open an automation algorithm session in the app and then click Run, the app calls the checkSetup method 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 calls the terminate method.

The diagram shows this flow of execution for the labeling apps.

  • Use the checkSetup method 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.

  • Use the initialize method to initialize the state for your custom algorithm by using the frame.

  • Use the run method to implement the core of the algorithm that computes and returns labels for each frame.

  • Use the terminate method to clean up or terminate the state of the automation algorithm after the algorithm runs.

See Also

Apps

Functions

Related Topics

Related Topics