|
|
VisionWorks Toolkit ReferenceApril 8, 2016 | 1.4 Release |
This tutorial demonstrates delay object usage.
A delay is a special kind of VisionWorks framework objects that contains a temporally-delayed fixed-size list of other data objects. All objects in delay have the same metadata (dimensions, format, etc.). Delay object might be used in scenarios like feature tracking or video stabilization, which requires processing a sequence of frames from input video stream.
This tutorial implements simple feature tracking pipeline based on the Optical Flow PyrLK vision primitive. It tracks features from Frame # (i - 2) to Frame # i. For this purpose, three delay objects are used: the first for input frames, the second for gaussian pyramids, and the third for features arrays.
The first step is to create the delay objects. The vxCreateDelay method accepts the number of slots in the delay object and exemplar object. The exemplar is used only to pass metadata to the delay's constructor. Note that vxCreateImage and similar methods do not allocate memory for objects (VisionWorks uses delayed allocation scheme), so the exemplar creation is a fast operation.
The next step is to initialize the delay objects with the first two frames from video sequence. To get the data object from delay's slot by index, the vxGetReferenceFromDelay method is used. The delay index is in the range \( [-num\_slots + 1, 0] \), where 0 corresponds to the current object.
After the initialization, the delay has the following structure:
The third step is graph creation for the following pipeline:
Delay's slots can be used as nodes parameters. In this case, nodes are bound to a specific delay slot and not to its content. When delay is aged, nodes use the same slot with updated data.
Now you can write a loop that fetches frames from a video stream and processes them.
After the first fetch, the delay has the following structure:
The graph uses Frame #0 and Frame #2 as input for the Optical Flow primitive.
The last step is to age delay. This means that the reference from Slot 0 goes to Slot -1, reference from Slot -1 goes to Slot -2, etc.
After the aging, the delay has the following structure:
The next fetch fills Slot 0 with Frame #3 and the graph uses Frame #1 and Frame #3 as input for Optical Flow.