Main Content

Use Custom Image Source Reader for Labeling

TheVideo LabelerandGround Truth Labeler(Automated Driving Toolbox)apps enable you to label ground truth data in a video or sequence of images.

You can use a custom reader to import any video or sequence of images that is supported by theVideoReaderobject orimreadfunction. First, create a custom reader function. Then, load the custom reader function and corresponding image data source into theVideo LabelerorGround Truth Labelerapp. TheImage Labelerapp 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)
In this example,readerFcnis the name of the custom reader function.

The custom reader function loads an image fromsourceName, which corresponds to the current timestamp specified bycurrentTimestamp. For example, suppose you want to load the image at the third timestamp for a timestampsdurationvector that runs from 1 to 5 seconds. To specifycurrentTimestamp, at the MATLAB®command prompt, enter this code.

timestamps = seconds(1:5); currIdx = 3; currentTimestamp = timestamps(currIdx);

TheoutputImageoutput from the custom function must be a grayscale or RGB image in any format supported by theimshowfunction. ThecurrentTimestampoutput 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 theVideo Labelerapp, first create agroundTruthDataSource对象。这个对象存储数据的源文件nd timestamps. Specify the name of the data source, the custom reader function handle that reads the data, and the timestamps by using this syntax.

gtSource= groundTruthDataSource(sourceName,readerFcn,timestamps)

To load this object into the app, at the MATLAB command prompt, enter this code.

videoLabeler(gtSource)

Alternatively, on the toolstrip of theVideo Labelerapp, selectImport>Custom Reader. Then, in the Load Custom Data Source dialog box, specifyCustom reader functionas a function handle and also specifyData 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 theGround Truth Labeler(Automated Driving Toolbox)app, on the app toolstrip, selectImport>Add Signals. Then, in the dialog box, setSource TypetoCustom Image. You can then specify the custom reader function, data source name, and timestamps, and then clickAdd Sourceto load the image data source.

See Also

Apps

Objects

Related Topics