Main Content

CameraData

Store sequence of camera data

Since R2024b

Description

The CameraData object stores a sequence of camera data.

Creation

Description

camData = scenariobuilder.CameraData creates an empty CameraData object, camData.

example

camData = scenariobuilder.CameraData(timestamps,frames) creates a CameraData object, camData, with the Timestamps and Frames properties set by the timestamps and frames arguments, respectively. Additionally, this syntax sets the SampleRate, SampleTime, TimeDuration, and NumSamples properties.

example

camData = scenariobuilder.CameraData(video) creates a CameraData object, camData, containing image data extracted from the specified video video.

example

camData = scenariobuilder.CameraData(___,Name=Value) sets writable properties using one or more name-value arguments. For example, Name="camera1" specifies the name of the camera sensor as "camera1".

Note

This object 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.

Input Arguments

expand all

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.

This argument sets the Timestamps property.

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.

This argument sets the Frames property.

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.

This argument sets the Frames and Timestamps properties.

Data Types: char | string

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where 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.

Example: scenariobuilder.CameraData(Name="camera1") specifies the name of the camera sensor as "camera1".

Name of the camera sensor, specified as a string scalar or character vector.

This argument sets the Name property.

Data Types: char | string

Optional camera sensor parameters, specified as camera parameters, such as a monoCamera object.

This argument sets the SensorParameters property.

Optional camera attributes, 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.

This argument sets the Attributes property.

Data Types: cell

Properties

expand all

Name of the camera sensor, specified as a string scalar or character vector.

Data Types: char | string

This property is read-only.

Number of image frames, represented as a nonnegative integer.

Data Types: uint8 | uint16 | uint32 | uint64

This property is read-only.

Time duration for which the camera data was acquired, represented as a nonnegative scalar. Units are in seconds.

Data Types: double

This property is read-only.

Mean sample rate of the camera data, represented as a nonnegative scalar. This value defines the number of camera frames per second. Units are in hertz.

Data Types: double

This property is read-only.

Mean sample time of the camera data, represented as a nonnegative scalar. This value defines the mean time interval between two consecutive image frames. Units are in seconds.

Data Types: double

This property is read-only after object creation. To set this property, use the timestamps argument when calling the scenarioBuilder.CameraData function.

Timestamps of the camera data, represented 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 property 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.

When you initialize the object with timestamps and frames, the object arranges the data by the input timestamps in increasing order.

When you initialize the object with video, the object assigns the timestamps in the increasing order, which is linearly spaced from 0 to the duration of the video.

This property is read-only after object creation. To set this property, use the frames argument when calling the scenarioBuilder.CameraData function.

Sequence of image frames, represented as an N-by-1 string array. N is the number of timestamps. Each element in the array represents an image filename, an absolute or a relative path of an image file.

Optional camera sensor parameters, specified as camera parameters, such as a monoCamera object.

Optional camera attributes, 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

Object Functions

addAdd data to camera data object
removeRemove data from sensor data object
readRead data from sensor data object
copyCreate copy of sensor data object
cropCrop data from sensor data object
synchronizeSynchronize sensor data with reference sensor information
playPlay video from camera data object
datastoreCreate datastore from sensor data object
normalizeTimestampsNormalize timestamps of sensor data object

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 a camera data object using the specified file.

camData = scenariobuilder.CameraData(filePath)
camData = 
  CameraData with properties:

                Name: ''

          NumSamples: 700
            Duration: 35
          SampleRate: 20
          SampleTime: 0.0501
          Timestamps: [700×1 double]

              Frames: {700×1 cell}
    SensorParameters: []

          Attributes: []

Play the camera data object.

play(camData)

Create an image datastore from the images in the current working directory attached to the example as supporting files.

imageDS = imageDatastore(pwd);

Specify timestamps for each image frame.

timestamps = (0.1:0.1:1)';

Create a camera data object using the specified timestamps and image datastore.

camData = scenariobuilder.CameraData(timestamps,imageDS)
camData = 
  CameraData with properties:

                Name: ''

          NumSamples: 10
            Duration: 0.9000
          SampleRate: 11.1111
          SampleTime: 0.1000
          Timestamps: [10×1 double]

              Frames: {10×1 cell}
    SensorParameters: []

          Attributes: []

Play the camera data object.

play(camData)

Version History

Introduced in R2024b