DriveWorks SDK Reference
4.0.0 Release
For Test and Development only

Dense Optical Flow Workflow

Initialization

NVIDIA® DriveWorks includes a sample pipeline demonstrating the Dense Optical Flow module across multiple video frames. The following summarizes the sample's initialization steps:

Initialize the parameters for the module with default values:

dwDenseOpticalFlowParameters params;

Select the processors for the corresponding stages to run on:

params.processorNVENC = DW_PROCESSOR_TYPE_NVENC_0;
params.processorPVA = DW_PROCESSOR_TYPE_PVA_0;

Set input image size dimensions:

params.imageWidth = 1280;
params.imageHeight = 800;

Initialize the Dense Optical Flow module:

Finally, the output image must be allocated by the application. This can be achieved by acquiring the required properties and using the dwImage API:

dwImageProperties outputProperties;
dwImageHandle_t outputImage;
dwImage_create(&imageOutput, outputProperties, sdk);

Process

DriveWorks accepts two images as input: a reference image, and a template image. These two are used to compute the motion vectors.

The input images must have the following format: DW_IMAGE_FORMAT_YUV420_UINT8_SEMIPLANAR.

The output image has the following format: `DW_IMAGE_FORMAT_RG_INT16. The R and G channels represent motion in the X and Y dimensions, respectively.

imageYUV420,
imageRefYUV420,
dof);

Release

Finally, release the resources used:

For a demonstration of this workflow, see Dense Optical Flow Sample.