Write video sequence to video file
writes sequences of ground truth data to separate files,
filenames = writeVideoScenes(
that correspond to time ranges,
timeRanges. Video files are written to
the folders specified by the
The function writes video scenes using the image data and corresponding timestamp data
contained in the specified
groundTruth objects. All nonimage data, such
as lidar, is ignored.
specifies options using name-value arguments, in addition to any combination of input
arguments from previous syntaxes. For example,
filenames = writeVideoScenes(___,
progress information while writing video scenes to files.
Load ground truth scene label definitions and label data into the workspace.
data = load("groundTruthSceneLabels.mat"); labelDefinitions = data.labelDefinitions; labelData = data.labelData;
Create a ground truth data source using a video file.
gSource = groundTruthDataSource("viptrain.avi");
Create a ground truth object using the ground truth data source.
gTruth = groundTruth(gSource,labelDefinitions,labelData);
Gather all the scene time ranges and the scene labels.
[timeRanges,sceneLabels] = sceneTimeRanges(gTruth);
Select a folder in the temp directory to write the video scenes to.
rootFolder = fullfile(tempdir,"videoScenes");
Use the scene label names as folder names.
folderNames = sceneLabels;
Write the video scenes to the "
videoScenes" folder. Specify the subfolder names for each duration as the scene label names.
filenames = writeVideoScenes(gTruth,timeRanges,rootFolder,folderNames);
[==================================================] 100% Elapsed time: 00:00:02 Estimated time remaining: 00:00:00
timeRanges— Time ranges of ground truth source data
Time ranges of ground truth source data, specified as an M-by-1
cell array for a
groundTruth object or an
M-by-N cell array for a
groundTruthMultisignal object. M is the number
of elements in
gTruth and N represents the
number of signals per element. Each cell of the array contains a
T-by-2 duration matrix, where T is the number of
time ranges in the corresponding element of
gTruth. Each row of the
matrix corresponds to a time range in the ground truth data for which a scene label has
been applied, specified in the form [rangeStart
folderNames— Folder names
Folder names for the video scenes, specified as an M-by-1 cell
array for a
groundTruth object or an
M-by-N cell array for a
groundTruthMultisignal object. Each cell in the cell array
corresponds to an element of
gTruth, and contains a
T-by-1 vector of strings or categorical vector that specifies the
paths to the folders for the corresponding time ranges.
You must specify each folder name must be specified as a full path or as a relative
path from the current folder. When you specify a folder name that does not exist, the
function creates a new folder with the specified name. When writing video scene files,
the function overwrites files with the same name that already exists in the specified
folder. For example, if you call the
writeVideoScenes function twice
with the same input arguments, the files output by the second function call overwrite
those from the first.
To select and write specific signals in a
object to a specified location, use the
selectLabelsBySignalName (Automated Driving Toolbox) function before calling the
rootFolder— Root folder name
Root folder name to prepend to each of the folder names, specified as a character vector or a string scalar.
Specify optional pairs of
Name is the argument name and
Value is the
corresponding value. Name-value arguments must appear after other arguments, but the order
of the pairs does not matter.
writeVideoScenes(gTruth,timeRanges,folderNames,Verbose=true)displays progress information while writing video scenes to files.
NamePrefix— File name prefix
File name prefix, specified as an array of strings or a cell array of character
vectors. Default values depend on the
gTruth input type:
groundTruth object — The function uses the file names
(without their extension) in the
DataSource property of the
groundTruthMultisignal object — The function uses the
input signal names.
VideoProfile— Video profile
"Motion JPEG AVI"(default) |
"Motion JPEG 2000"|
Video profile for writing video scenes, specified as one of the video profiles
listed in the table. The
VideoProfile argument usage is the same as
profile argument of the
|Value of ||Description|
Motion JPEG 2000 file with lossless compression
AVI file using Motion JPEG encoding
Motion JPEG 2000 file
MPEG-4 file with H.264 encoding (systems with Windows® 7 or later, or macOS 10.7 and later)
Uncompressed AVI file with
Uncompressed AVI file with indexed video
Uncompressed AVI file with grayscale video
Verbose— Display progress on screen
Display progress on screen, specified as a logical
filenames— Full path file names
Full path file names to the saved video scenes, returned as an
M-by-1 cell array of T-by-1 vector of strings.
M is the number of elements in the
input argument. T is the number of time ranges in the corresponding
gTruth. Each element of the vector of strings specifies
the full path to the saved video scene for the corresponding time range.