DriveWorks SDK Reference
3.0.4260 Release
For Test and Development only

Dense Optical Flow Sample
SW Release Applicability: This sample is available in both NVIDIA DriveWorks and NVIDIA DRIVE Software releases.


The Dense Optical Flow module sample demonstrates the Dense Optical Flow pipeline on multiple hardware units:

  • VIC (Video Image Compositor).
  • NVIDIA NVENC (NVIDIA Video Encoder).
  • PVA (Programmable Vision Accelerator).

The Dense Optical Flow sample accepts RAW videos, h264 videos, or live camera input data from an AR0231 (revision >= 4) sensor. It then applies an optical flow algorithm to estimate motion vectors between frames.

Running the Sample

The DenseOpticalFlow sample, sample_denseopticalflow, accepts the following optional parameters. If none are specified, it performs detections on a supplied pre-recorded video.

./sample_denseopticalflow --input-type=[video|camera]


        Defines if the input is from live camera or from a recorded video.
        Live camera is supported only on NVIDIA DRIVE(tm) platforms.
        It is not supported on Linux (x86 architecture) host systems.
        Default value: video

        Specifies the absolute or relative path of a raw, lraw or h264 recording.
        Only applicable if --input-type=video
        Default value: path/to/data/samples/stereo/left_1.h264

        Specifies a supported AR0231 `RCCB` sensor.
        Only applicable if --input-type=camera.
        Default value: ar0231-rccb-bae-sf3324

        Is the group where the camera is connected to.
        Only applicable if --input-type=camera.
        Default value: a

        Indicates the camera index on the given port.
        Default value: 0

        Setting this parameter to 1 when running the sample on Xavier B accesses the camera
        on Xavier A.
        Applicable only when --input-type=camera.
        Default value: 0

        Indicates the quality and the performance of Dense Optical Flow algorithm:
        - HP: High Performance
        - UHP: Ultra High Performance
        - HQ: High Quality
        Default value: HP

        Indicates on which Nvidia Video Encoder the corresponding stage of the pipeline is to be executed.
        Default value: 0

        Indicates on which PVA engine the corresponding stage of the pipeline is to be executed.
        Default value: 0


To run the sample on a video

./sample_denseopticalflow --input-type=video --video=<video file>

To run the sample on a camera on NVIDIA DRIVE platforms

./sample_dense_opticalflow --input-type=camera --camera-type=<camera type> --camera-group=<camera group> --camera-index=<camera idx on camera group>

To run the sample on non-default engines

./sample_denseopticalflow --nvencNo=1 --pvaNo=1


The sample creates a window and displays a video with two sections. The section above demonstrates the original video, whereas the section below shows the result of Dense Optical Flow with color coding presented at

Dense Optical Flow

Additional information

For more information, see Dense Optical Flow.