1 # Copyright (c) 2019-2020, NVIDIA CORPORATION. All rights reserved.
3 @page denseopticalflow_usecase1 Dense Optical Flow Workflow
5 @note SW Release Applicability: This tutorial is applicable to modules in both **NVIDIA DriveWorks** and **NVIDIA DRIVE Software** releases.
9 NVIDIA<sup>®</sup> DriveWorks includes a sample pipeline demonstrating the Dense Optical Flow module across multiple video frames. The following summarizes the sample's initialization steps:
11 Initialize the parameters for the module with default values:
14 dwDenseOpticalFlowParameters params;
15 dwDenseOpticalFlow_initDefaultParams(¶ms);
18 Select the processors for the corresponding stages to run on:
21 params.processorNVENC = DW_PROCESSOR_TYPE_NVENC_0;
22 params.processorPVA = DW_PROCESSOR_TYPE_PVA_0;
25 Set input image size dimensions:
28 params.imageWidth = 1280;
29 params.imageHeight = 800;
32 Initialize the Dense Optical Flow module:
35 dwDenseOpticalFlowHandle_t dof;
36 dwDenseOpticalFlow_initialize(&dof, ¶ms, sdk);
39 Finally, the output image must be allocated by the application. This can be achieved by acquiring the required properties and
40 using the dwImage API:
43 dwImageProperties outputProperties;
44 dwDenseOpticalFlow_getOutputImageProperties(&outputProperties, dof);
46 dwImageHandle_t outputImage;
47 dwImage_create(&imageOutput, outputProperties, sdk);
52 DriveWorks accepts two images as input: a reference image, and a template image. These two are used to compute the motion vectors.
54 The input images must have the following format: `::DW_IMAGE_FORMAT_YUV420_UINT8_SEMIPLANAR`.
56 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.
59 dwDenseOpticalFlow_calculateOpticalFlow(outputImage,
67 Finally, release the resources used:
70 dwImage_destroy(imageOutput);
71 dwDenseOpticalFlow_release(dof);
74 For a demonstration of this workflow, see @ref dwx_denseopticalflow_sample.