Use Custom Image Source Reader for Labeling
You can use a custom reader to import any video or sequence of images that is supported by
VideoReader object or
imread function. First, create a custom reader
function. Then, load the custom reader function and corresponding image data source into the
Video Labeler or Ground Truth Labeler app. The Image Labeler app does
not support custom data source readers.
Create Custom Reader Function
First, specify a custom reader as a function handle. The custom reader must have this syntax.
outputImage = readerFcn(sourceName,currentTimestamp)
readerFcnis the name of the custom reader function.
The custom reader function loads an image from
corresponds to the current timestamp specified by
example, suppose you want to load the image at the third timestamp for a timestamps
duration vector that runs from 1 to 5 seconds. To specify
currentTimestamp, at the MATLAB® command prompt, enter this
timestamps = seconds(1:5); currIdx = 3; currentTimestamp = timestamps(currIdx);
outputImage output from the custom function must be a grayscale or
RGB image in any format supported by the
imshow function. The
currentTimestamp output is a scalar
value that corresponds to the current frame that the function is executing.
Import Data Source into Video Labeler App
To import a custom data source into the Video Labeler app,
first create a
groundTruthDataSource object. This object stores
the data source files and timestamps. Specify the name of the data source, the custom reader
function handle that reads the data, and the timestamps by using this
To load this object into the app, at the MATLAB command prompt, enter this code.
Alternatively, on the toolstrip of the Video Labeler app, select Import > Custom Reader. Then, in the Load Custom Data Source dialog box, specify Custom reader function as a function handle and also specify Data source name. In addition, you must import corresponding timestamps from the MATLAB workspace.
Import Data Source into Ground Truth Labeler App
To import the custom image data source into the Ground
Truth Labeler (Automated Driving Toolbox) app, on the app toolstrip, select Import > Add Signals. Then, in the dialog box, set Source Type to
Custom Image. You can then specify the custom reader function,
data source name, and timestamps, and then click Add Source to load the
image data source.