Label Ground Truth for Multiple Signals

After loading the video and lidar point cloud sequence signals into the Ground Truth Labeler app, as described in the Load Ground Truth Signals to Label procedure, create label definitions and label the signal frames. In this example, you label only a portion of the signals for illustrative purposes.

Create Label Definitions

Label definitions contain the information about the labels that you mark on the signals. You can create label definitions interactively within the app or programmatically by using a labelDefinitionCreatorMultisignal object. In this example, you create label definitions in the app.

Create ROI Label

An ROI label is a label that corresponds to a region of interest (ROI) in a signal frame. You can define these ROI label types.

  • Rectangle/Cuboid — Draw bounding box labels around objects, such as vehicles. In image signals, you draw labels of this type as 2-D rectangular bounding boxes. In point cloud signals, you draw labels of this type as 3-D cuboid bounding boxes.

  • Line — Draw linear ROIs to label lines, such as lane boundaries.

  • Pixel label — Draw pixels to label various classes, such as road or sky, for semantic segmentation.

For more details about these ROI label definitions, see ROI Labels, Sublabels, and Attributes.

Create an ROI label definition for labeling cars in the signal frames.

  1. On the ROI Labels pane in the left pane, click Label.

  2. Create a Rectangle/Cuboid label named car.

  3. From the Group list, select New Group and name the group Vehicles. Adding labels to groups is optional.

  4. Click OK. The Vehicles group name appears on the ROI Labels tab with the label car under it.

The car label is drawn differently on each signal. On the video, car is drawn as a 2-D rectangular bounding box of type Rectangle. On the point cloud sequence, car is drawn as a 3-D cuboid bounding box of type Cuboid.

Create ROI Sublabel

A sublabel is a type of ROI label that corresponds to a parent ROI label. Each sublabel must belong to, or be a child of, a label definition that is in the ROI Labels tab. For example, in a driving scene, a vehicle label can have sublabels for headlights, license plates, or wheels. For more details about sublabels, see ROI Labels, Sublabels, and Attributes.

Create an ROI sublabel definition for labeling the brake lights of the labeled cars.

  1. Select the parent label of the sublabel. On the ROI Labels tab in the left pane, click the car label to select it.

  2. Click Sublabel.

  3. Create a Rectangle sublabel named brakeLight. Cuboid sublabels are not supported, so this sublabel applies only for the video signal. Click OK.

    The brakeLight sublabel appears in the ROI Labels tab under the car label. The sublabel and parent label have the same color.

Create ROI Attribute

An ROI attribute specifies additional information about an ROI label or sublabel. For example, in a driving scene, attributes can include the type or color of a vehicle. You can define ROI attributes of these types.

  • Numeric Value — Specify a numeric scalar attribute, such as the number of doors on a labeled vehicle.

  • String — Specify a string scalar attribute, such as the color of a vehicle.

  • Logical — Specify a logical true or false attribute, such as whether a vehicle is in motion.

  • List — Specify a drop-down list attribute of predefined strings, such as make or model of a vehicle.

For more details about these attribute types, see ROI Labels, Sublabels, and Attributes.

Create an attribute to describe whether a labeled brake light is on or off.

  1. On the ROI Labels tab in the left pane, select the brakeLight sublabel and click Attribute.

  2. In the Attribute Name box, type isOn. Set the attribute type to Logical. Leave Default Value set to Empty and click OK.

  3. In the ROI Labels tab, expand the brakeLight sublabel definition. The Attribute box for this sublabel now contains the isOn attribute.

Create Scene Label

A scene label defines additional information across all signals in a scene. Use scene labels to describe conditions, such as lighting and weather, or events, such as lane changes.

Create a scene label to apply to the signal frames.

  1. In the left pane of the app, select the Scene Labels tab.

  2. Click Define new scene label, and in the Label Name box, enter a scene label named daytime.

  3. Change the color of the label definition to light blue to reflect the nature of the scene label. Under the Color parameter, click the color preview and select the standard light blue colors. Then, click OK to close the color selection window.

  4. Leave the Group parameter set to the default of None and click OK. The Scene Labels pane shows the scene label definition.

Verify Label Definitions

Verify that your label definitions have this setup.

  1. The ROI Labels tab contains a Vehicles group with a car label of type Rectangle/Cuboid.

  2. The car label contains a sublabel named brakeLight.

  3. The brakeLight sublabel contains an attribute named isOn.

  4. The Scene Labels tab contains a light blue scene label named daytime.

To edit or delete a label definition, right-click that label definition and select the appropriate edit or delete option. To save these label definitions to a MAT-file for use in future labeling sessions, on the Label tab of the app toolstrip, select Save > Label Definitions.

In future labeling sessions, if you need to reorder label definitions or move them to different groups, you can drag and drop them in the label definition panes.

Label Video Using Automation

Use the car label to label one of the cars in a portion of the video. To assist with the labeling process, use one of the built-in label automation algorithms.

  1. Select the time interval to label. Specify an interval from 8 to 10 seconds, during which the car in front is close to the ego vehicle. In the text boxes below the video, enter these times in this order:

    1. In the Current box, type 8 and press Enter.

    2. In the Start Time box, type 8 so that the slider is at the start of the time interval.

    3. In the End Time box, type 10.

    The range slider and text boxes are set to this 8–10 second interval. The red flags indicate the start and end of the interval.

    The app displays signal frames from only this interval, and automation algorithms apply to only this interval. To expand the time interval to fill the entire playback section, click Zoom In Time Interval.

  2. In the labeling window, click the video signal to select it. You can automate only one signal at a time, so you must select the signal that you want to automate.

  3. Select the label that you want to automate. In the ROI Labels tab, click the car label.

  4. From the app toolstrip, select Select Algorithm > Temporal Interpolator. This algorithm estimates rectangle ROIs between image frames by interpolating the ROI locations across the time interval.

  5. Click Automate. The app prompts you to confirm that you want to label only a portion of the video. Click Yes. An automation session for the video opens. The right pane of the automation session displays the algorithm instructions.

  6. At the start of the time interval, click and drag to draw a car label around the car in the center of the frame. For this algorithm, you can draw only one label per frame. Labeling the other car would require a separate automation session.

    By default, the car label appears only when you move your pointer over it. Optionally, to always display labels, on the app toolstrip, set Show ROI Labels to Always.

  7. Drag the slider to the last frame and draw a car label around the same car in this frame. Optionally, to improve automation results, label the car in intermediate frames.

  8. Click Run. The automation algorithm applies the car label to the intermediate frames. Drag the slider to view the results. If necessary, manually adjust the labels to improve their accuracy.

  9. When you are satisfied with the results, click Accept to close the session and apply the labels to this portion of the video.

Label Point Cloud Sequence Using Automation

Use the same car label definition from the previous procedure to label a car in the point cloud sequence. To assist with the labeling process, use a built-in label automation algorithm designed for point cloud labeling. In this example, you label the ego vehicle, which is easier to see in the lidar point cloud sequence than the front car.

  1. At the bottom of the app, verify that the time range is still set to 8 to 10 seconds.

  2. In the labeling window, click the point cloud sequence to select it.

  3. In the ROI Labels tab, click the car label definition.

  4. On the Label tab of the app toolstrip, select Select Algorithm > Point Cloud Temporal Interpolator. This algorithm estimates cuboid ROIs between point cloud frames by interpolating the ROI locations across the time interval.

  5. Click Automate. The app prompts you to confirm that you want to label only a portion of the point cloud sequence. Click Yes. An automation session for the point cloud sequence opens. The right pane of the automation session displays the algorithm instructions.

  6. At the start of the time interval, draw a car label around the ego vehicle.

    1. Zoom in on the car, using either the scroll wheel or the Zoom In button at the top-right corner of the frame. You can also use the Pan button to center the car in the frame.

    2. On the ROI Labels tab in the left pane, click the car label. Drag the gray preview cuboid until it highlights the ego vehicle.

    3. Click the signal frame to create the label. The label snaps to the highlighted portion of the point cloud.

    4. Adjust the cuboid label until it fully encloses the car. To resize the cuboid, click and drag one of the cuboid faces. To move the cuboid, hold Shift and click and drag one of the cuboid faces.

      For additional tips and techniques for labeling point clouds, see Label Lidar Point Clouds for Object Detection.

  7. Click the cuboid and press Ctrl+C to copy it. Then, drag the slider to the last frame and paste (Ctrl+V) the cuboid into the new frame at the same position. Optionally, to improve automation results, manually adjust the position of the copied label.

  8. Click Run. The automation algorithm applies the car label to the intermediate frames. Drag the slider to view the results. If necessary, manually adjust the labels to improve their accuracy.

  9. When you are satisfied with the results, click Accept to close the session and apply the labels to this portion of the point cloud sequence.

Label with Sublabels and Attributes Manually

Manually label one frame of the video with the brakeLight sublabel and its isOn attribute. Lidar point cloud signals do not support sublabels and attributes, so you cannot label the point cloud sequence.

  1. At the bottom of the app, verify that the time range is still set to 8 to 10 seconds. If necessary, drag the slider to the first frame of the time range.

  2. In the ROI Labels tab, click the brakeLight sublabel definition to select it.

  3. Hide the point cloud sequence. On the Label tab of the app toolstrip, under Show/Hide Signals, clear the check mark for the lidar point cloud sequence. Hiding a signal only hides the display. The app maintains the labels for hidden signals, and you can still export them.

  4. Expand the video signal to fill the entire labeling window.

  5. In the video frame, select the drawn car label. The label turns yellow. You must select the car label (parent ROI) before you can add a sublabel to it.

  6. Draw brakeLight sublabels for the car. Optionally, set Show ROI Labels to Always so that you can confirm the association between the car label and its sublabels.

  7. On the video frame, select one of the brakeLight sublabels. Then, on the Attributes and Sublabels pane in the right pane, set the isOn attribute to True. Repeat this step for the other sublabel.

For more details about working with sublabels and attributes, see Use Sublabels and Attributes to Label Ground Truth Data (Computer Vision Toolbox).

Label Scene Manually

Apply the daytime scene label to the entire scene.

  1. Expand the time interval back to the entire duration of all signals. If you zoomed in on the time interval, first click Zoom Out Time Interval. Then, drag the red flags to the start and end of the range slider.

  2. In the left pane of the app, select the Scene Labels tab.

  3. Select the daytime scene label definition.

  4. Above the label definition, click Time Interval. Then, click Add Label. A check mark appears for the daytime scene label indicating that the label now applies to all frames in the time interval.

View Label Summary

With all labels, sublabels, and attributes applied to at least one frame of a signal, you can now optionally view a visual summary of the ground truth labels. On the app toolstrip, click View Label Summary. For more details, see View Summary of Ground Truth Labels (Computer Vision Toolbox).

Save App Session

On the app toolstrip, select Save and save a MAT-file of the app session. The saved session includes the data source, label definitions, and labeled ground truth. It also includes your session preferences, such as the layout of the app.

You can now either close the app session or continue to the Export Ground Truth Labels for Multiple Signals step, where you export the labels.

Related Topics