This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Create Automation Algorithm for Labeling

The Image Labeler, Video Labeler, and Ground Truth Labeler (requires Automated Driving System Toolbox™) apps enable you to label ground truth data in an image collection, video, or image sequence. You can use an automation algorithm to automatically label your data by creating and importing a custom automation algorithm.

Create Custom Label Automation Algorithm for Labeling App

The 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 with your loaded data source:

  1. Create the automation folder: Create a +vision/+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 +vision/+labeler/ folder hierarchy as follows:

    projectFolder = fullfile('local','MyProject');
    automationFolder = fullfile('+vision','+labeler');
    mkdir(projectFolder,automationFolder)

  2. Define a class that inherits from the AutomationAlgorithm class: At the MATLAB command prompt, enter the appropriate command to open the labeling app you want: imageLabeler, videoLabeler, or groundTruthLabeler. Then click Select Algorithm > Add Algorithm > Create new algorithm to open the vision.labeler.AutomationAlgorithm class template. Define your algorithm by following the instructions in the header and comments in the class.

  3. Save the file: Save the file to the +vision/+labeler package folder to use your custom algorithm from within the app. To add a folder to the path, use the addpath function.

  4. Refresh the algorithm list: To start using your custom algorithm, refresh the algorithm list for it to display in the list of algorithms. In the app, click Select Algorithm > Refresh list in the app.

Import Custom Algorithm into Labeling App

Alternatively, to import your custom algorithm, click Select Algorithm > Add Algorithm > Import Algorithm and then refresh the list.

Custom Algorithm Execution

The properties and methods in your automation algorithm class define how the class interacts with the Automate button in the labeler app.

When you click Automate, the app checks each label definition in the ROI Label Definition and Scene Label Definition 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 the checkLabelDefinition 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 PixelLabel.

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.

When you first run the algorithm, the app calls the checkSetup method to check if it is ready for execution. If the method returns true, the app calls the initialize method and then the run method on every image selected for automation. Then, the app calls the terminate method.

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 before running the algorithm. Use the initialize method to initialize the state for your custom algorithm by using the image. Use the run method to implement the core of the algorithm that computes and returns labels for each image. Use the terminate method to clean up or terminate the state after the algorithm runs.

See Also

Apps

Functions

Related Examples

More About