%% Select Ground Truth Labels by Label Type
% Select ground truth labels from a
% |<docid:driving_ref#mw_42782d95-09f4-4844-91ee-44ddd8357f59
% groundTruthMultisignal>| object by specifying a label type.

% Copyright 2019 The MathWorks, Inc.

%%
% Load a |groundTruthMultisignal| object containing ROI and scene label
% data for a video and corresponding lidar point cloud sequence. The helper
% function used to load this object is attached to the example as a
% supporting file.

gTruth = helperLoadGTruthVideoLidar;

%%
% Inspect the label definitions. The object contains definitions for
% rectangle, cuboid, and scene label types.

gTruth.LabelDefinitions

%%
% Inspect the ROI labels. The object contains labels for the lidar point
% cloud sequence and the video.

gTruth.ROILabelData

%%
% Create a new |groundTruthMultisignal| object that contains only labels
% that are of type cuboid.

labelTypes = labelType.Cuboid;
gtLabel = selectLabelsByLabelType(gTruth,labelTypes);

%%
% For the original and new objects, inspect the first five rows of label
% data for the lidar point cloud sequence. Because the lidar point cloud
% signal in the original object contains only cuboid labels, the new object
% contains the same label data for the lidar sequence as the original
% object.

lidarLabels = gTruth.ROILabelData.lidarSequence;
lidarLabelsSelection = gtLabel.ROILabelData.lidarSequence;

numrows = 5;
head(lidarLabels,numrows)
head(lidarLabelsSelection,numrows)

%%
% For the original and new objects, inspect the first five rows of label
% data for the video. Because video signals do not support the |Cuboid|
% label type, the new object contains no label data for the video.

videoLabels = gTruth.ROILabelData.video_01_city_c2s_fcw_10s;
videoLabelsSelection = gtLabel.ROILabelData.video_01_city_c2s_fcw_10s;

head(videoLabels,numrows)
head(videoLabelsSelection,numrows)