Main Content

add

Add data to camera data object

Since R2024b

Description

add(camData,timestamps,frames) adds the specified image frames frames, with their corresponding timestamps timestamps, to the camera data object camData.

example

add(camData,video) adds image data extracted from video video to the camera data object camData. To use this syntax, you must specify camData as an empty CameraData object.

example

add(___,Attributes=attributes) adds the optional camera attributes attributes to the camera data object camData, in addition to any combination of input arguments from the previous syntaxes.

Note

This function requires the Scenario Builder for Automated Driving Toolbox™ support package. You can install the Scenario Builder for Automated Driving Toolbox support package from the Add-On Explorer. For more information about installing add-ons, see Get and Manage Add-Ons.

example

Examples

collapse all

Specify a sequence of image filenames.

images = {'Frame01.png','Frame02.png','Frame03.png','Frame04.png','Frame05.png', ...
    'Frame06.png','Frame07.png','Frame08.png','Frame09.png','Frame10.png'}';

Specify timestamps for each image frame.

timestamps = (0.1:0.1:1)';

Create an empty camera data object.

camData = scenariobuilder.CameraData
camData = 
  CameraData with properties:

                Name: ''

          NumSamples: 0
            Duration: 0
          SampleRate: 0
          SampleTime: 0
          Timestamps: []

              Frames: []
    SensorParameters: []

          Attributes: []

Add data samples to the camera data object.

add(camData,timestamps,images)

Play the camera data object.

play(camData)

Specify the path of a video file.

filePath = fullfile(toolboxdir("driving"),"drivingdata","udacity\drive_segment_09_29_16\centerCamera.avi");

Create an empty camera data object.

camData = scenariobuilder.CameraData;

Add data samples from video to the camera data object.

add(camData,filePath)

Play the camera data object.

play(camData)

Input Arguments

collapse all

Camera data, specified as a CameraData object.

Timestamps of the camera data, specified as an N-element numeric column vector, an N-element datetime array, or an N-element duration array. N is the number of timestamps. Each element in the timestamps argument specifies the time at which the corresponding camera data was collected. If you specify an N-element numeric column vector, units must be in seconds.

Sequence of image frames, specified as an N-by-1 string array, N-by-1 cell array of character vectors, P-by-Q-by-R-by-N array, a string scalar, or an ImageDatastore object. N is the number of timestamps.

If you specify an N-by-1 string array or an N-by-1 cell array of character vectors, each element in the array represents an image filename, an absolute or relative path of an image file.

If you specify a P-by-Q-by-R-by-N array, P and Q are the height and width of the image, R is the number of color channels, and N is the number of image frames.

If you specify a string scalar, the string must specify an absolute or relative path to a folder containing image files.

Video filename, specified as a character vector or string scalar.

You can specify video as the absolute or relative path to your file. For example, if the file myFile.mp4 is in your current folder, C:\myFolder, you can specify video as "myFile.mp4" or "C:\myFolder\myFile.mp4".

For more information, see Supported Video and Audio File Formats.

Data Types: char | string

Optional camera attributes of the added camera data, specified as an N-by-1 cell array. N is the number of timestamps. Each cell contains the additional camera attributes, such as classification labels, detected at the corresponding timestamp.

Data Types: cell

Version History

Introduced in R2024b