VPI - Vision Programming Interface

3.0 Release

Dense Optical Flow

Algorithm used to estimate the motion vectors from previous image to current image. More...

Data Structures

struct  VPIOpticalFlowDenseSGMParams
 Dense optical flow parameters for semi-global matching pass. More...
 

Functions

VPIStatus vpiCreateOpticalFlowDense (uint64_t backends, int32_t width, int32_t height, VPIImageFormat inputFmt, const int32_t *gridSize, int32_t numLevels, VPIOpticalFlowQuality quality, VPIPayload *payload)
 Creates payload for vpiSubmitOpticalFlowDense. More...
 
VPIStatus vpiSubmitOpticalFlowDense (VPIStream stream, uint64_t backend, VPIPayload payload, VPIImage prevImg, VPIImage curImg, VPIImage mvImg)
 Runs dense Optical Flow on two frames, outputting motion vectors. More...
 
VPIStatus vpiSubmitOpticalFlowDensePyramid (VPIStream stream, uint64_t backend, VPIPayload payload, VPIPyramid prevPyr, VPIPyramid curPyr, VPIImage mvImg)
 Runs dense Optical Flow on two frames, outputting motion vectors. More...
 
VPIStatus vpiOpticalFlowDenseGetSGMParams (VPIPayload payload, VPIOpticalFlowDenseSGMParams *sgmParams)
 Retrieves the semi-global matching parameters set up in the Dense Optical Flow payload. More...
 
VPIStatus vpiOpticalFlowDenseSetSGMParams (VPIPayload payload, const VPIOpticalFlowDenseSGMParams *sgmParams)
 Sets the semi-global matching parameters to be used by the Dense Optical Flow operations with the given payload. More...
 

Detailed Description

Algorithm used to estimate the motion vectors from previous image to current image.

Refer to Dense Optical Flow for more details and usage examples.


Data Structure Documentation

◆ VPIOpticalFlowDenseSGMParams

struct VPIOpticalFlowDenseSGMParams

Dense optical flow parameters for semi-global matching pass.

Each pyramid level can be associated with different parameters. The first value in the arrays corresponds to the bottom (finer) level, the last corresponds to the top (coarse) level.

Definition at line 252 of file OpticalFlowDense.h.

+ Collaboration diagram for VPIOpticalFlowDenseSGMParams:
Data Fields
int32_t p1[VPI_MAX_PYRAMID_LEVEL_COUNT] P1 penalty value of semi-global matching algorithm used.

Only used by OFA backend and ignored by others.

int32_t p2[VPI_MAX_PYRAMID_LEVEL_COUNT] P2 penalty value of semi-global matching algorithm used.

Only used by OFA backend and ignored by others.

int32_t p2Alpha[VPI_MAX_PYRAMID_LEVEL_COUNT] Alpha value for adaptative P2 used in semi-global matching.
  • Valid values are 0 (disable adaptative P2), 1, 2, 4 or 8. Only used by OFA backend and ignored by others.
int32_t numPasses[VPI_MAX_PYRAMID_LEVEL_COUNT] Number of semi-global matching passes.
  • Valid range is from 1 to 3, inclusive. Only used by OFA backend and ignored by others.
int8_t includeDiagonals[VPI_MAX_PYRAMID_LEVEL_COUNT] Enable/disable diagonal directions in semi-global matching.
  • To disable, set it to 0, any other values will enable it. Only used by OFA backend and ignored by others.

Function Documentation

◆ vpiCreateOpticalFlowDense()

VPIStatus vpiCreateOpticalFlowDense ( uint64_t  backends,
int32_t  width,
int32_t  height,
VPIImageFormat  inputFmt,
const int32_t *  gridSize,
int32_t  numLevels,
VPIOpticalFlowQuality  quality,
VPIPayload payload 
)

#include </opt/nvidia/vpi3/include/vpi/algo/OpticalFlowDense.h>

Creates payload for vpiSubmitOpticalFlowDense.

Parameters
[in]backendsVPI backends that are eligible to execute the algorithm.
[in]width,heightDimensions of current and previous image. The output dimensions depend on the gridSize and the input dimensions.
  • Must be >= 0.
[in]gridSizeArray with grid sizes for each pyramid level. If working with input images, not pyramids, gridSize points to the single grid size used, as if it were for a pyramid with only one level. The first value in the array corresponds to the bottom (finer) level, the last corresponds to the top (coarse) level. Passing 1 allows for a dense grid. With 2 or more, the grid will be sparse. The output image dimensions depend on the first value in gridSize and the input dimensions.
[in]numLevelsNumber of pyramid levels to be processed. When using pyramids as inputs, this specifies the number of levels to be considered. When using images, numLevels must be 1.
  • On OFA, the number of levels is limited by the dimensions of the smallest pyramid level. It must be >= 32x32. Moreover, after dividing this smallest level by gridSize, the result must be >= 4x4.
  • Valid values:
    Backend minimum maximum :
    VPI_BACKEND_NVENC 1 1
    VPI_BACKEND_OFA 1 7
[in]inputFmtFormat of current and previous image/pyramid.
[in]qualityQuality of the dense optical flow algorithm.
[out]payloadPointer to the payload variable that receives the created handle.
Return values
VPI_IMAGE_FORMAT_INVALIDinputFmt is not supported.
VPI_ERROR_INVALID_ARGUMENTpayload is NULL.
VPI_ERROR_INVALID_ARGUMENTwidth, height, numLevels or gridSize outside valid range.
VPI_ERROR_INVALID_ARGUMENTbackends refers to an invalid backend.
VPI_ERROR_INVALID_OPERATIONBackend hardware not available.
VPI_ERROR_INVALID_OPERATIONBackend isn't enabled in current context.
VPI_ERROR_NOT_IMPLEMENTEDDense Optical Flow algorithm is not supported by given backends.
VPI_ERROR_INVALID_CONTEXTCurrent context is destroyed.
VPI_ERROR_OUT_OF_MEMORYCannot allocate required resources.
VPI_SUCCESSOperation executed successfully.

◆ vpiSubmitOpticalFlowDense()

VPIStatus vpiSubmitOpticalFlowDense ( VPIStream  stream,
uint64_t  backend,
VPIPayload  payload,
VPIImage  prevImg,
VPIImage  curImg,
VPIImage  mvImg 
)

#include </opt/nvidia/vpi3/include/vpi/algo/OpticalFlowDense.h>

Runs dense Optical Flow on two frames, outputting motion vectors.

Parameters
[in]streamThe stream where the operation will be queued in.
  • Must not be NULL.
  • Stream must have enabled the backends that will execute the algorithm.
[in]backendBackend that will execute the algorithm.
  • Must be the backend specified during payload creation or 0 as a shorthand to use this backend.
[in]payloadPayload created by vpiCreateOpticalFlowDense.
  • The number of pyramid levels specified in the payload must be 1.
[in]prevImgPrevious frame.
  • Must not be NULL.
  • Must have same format and dimensions as the one specified during payload creation.
  • Image must have enabled the backends that will execute the algorithm.
[in]curImgCurrent frame.
  • Must not be NULL.
  • Must have same format and dimensions as prevImg.
  • Image must have enabled the backends that will execute the algorithm.
[out]mvImgMotion vectors output.
  • Must not be NULL.
  • Image must have enabled the backends that will execute the algorithm.
  • The width and height depend on the input dimensions and grid size specified on the payload. It's calculated by:
    • output_width = (input_width + gridSize-1)/gridSize
    • output_height = (input_height + gridSize-1)/gridSize
  • Supported formats:
Return values
VPI_ERROR_INVALID_ARGUMENTstream is NULL.
VPI_ERROR_INVALID_ARGUMENTprevImg, curImg or mvImg are NULL.
VPI_ERROR_INVALID_ARGUMENTpayload is not generated using vpiCreateOpticalFlowDense.
VPI_ERROR_INVALID_ARGUMENTnumber of pyramid levels specified in payload is not 1.
VPI_ERROR_INVALID_ARGUMENTprevImg and curImg dimensions does not match the one associated with the payload.
VPI_ERROR_INVALID_IMAGE_FORMATprevImg and curImg format does not match the one associated with the payload.
VPI_ERROR_INVALID_PAYLOAD_TYPEpayload is invalid.
VPI_ERROR_INVALID_OPERATIONThe needed backends aren't enabled in stream, prevImg, curImg or mvImg.
VPI_SUCCESSOperation executed successfully.

◆ vpiSubmitOpticalFlowDensePyramid()

VPIStatus vpiSubmitOpticalFlowDensePyramid ( VPIStream  stream,
uint64_t  backend,
VPIPayload  payload,
VPIPyramid  prevPyr,
VPIPyramid  curPyr,
VPIImage  mvImg 
)

#include </opt/nvidia/vpi3/include/vpi/algo/OpticalFlowDense.h>

Runs dense Optical Flow on two frames, outputting motion vectors.

Parameters
[in]streamThe stream where the operation will be queued in.
  • Must not be NULL.
  • Stream must have enabled the backends that will execute the algorithm.
[in]backendBackend that will execute the algorithm.
  • Must be the backend specified during payload creation or 0 as a shorthand to use this backend.
[in]payloadPayload created by vpiCreateOpticalFlowDense.
[in]prevPyrPrevious pyramid frame.
  • Must not be NULL.
  • Must have same format and dimensions as the one specified during payload creation.
  • Pyramid height must be >= the number of pyramid levels specified in the payload.
  • Pyramid must have enabled the backends that will execute the algorithm.
[in]curPyrCurrent pyramid frame.
  • Must not be NULL.
  • Must have same format and dimensions as prevImg.
  • Number of pyramid levels must be the same as specified in the payload.
  • Pyramid must have enabled the backends that will execute the algorithm.
[out]mvImgMotion vectors output.
  • Must not be NULL.
  • Image must have enabled the backends that will execute the algorithm.
  • The width and height depend on the input dimensions and grid size of the bottom pyramid level specified in the payload. It's calculated by:
    • output_width = (input_width + gridSize-1)/gridSize
    • output_height = (input_height + gridSize-1)/gridSize
  • Supported formats:
Return values
VPI_ERROR_INVALID_ARGUMENTstream is NULL.
VPI_ERROR_INVALID_ARGUMENTprevPyr, cuurPyr or mvImg are NULL.
VPI_ERROR_INVALID_ARGUMENTpayload is not generated using vpiCreateOpticalFlowDense.
VPI_ERROR_INVALID_ARGUMENTprevPyr and cuurPyr dimensions does not match the one associated with the payload.
VPI_ERROR_INVALID_ARGUMENTprevPyr and curPyr number of Levels out of valid range.
VPI_ERROR_INVALID_IMAGE_FORMATprevPyr and curPyr format does not match the one associated with the payload.
VPI_ERROR_INVALID_PAYLOAD_TYPEpayload is invalid.
VPI_ERROR_INVALID_OPERATIONThe needed backends aren't enabled in stream, prevPyr, cuurPyr or mvImg.
VPI_SUCCESSOperation executed successfully.

◆ vpiOpticalFlowDenseGetSGMParams()

VPIStatus vpiOpticalFlowDenseGetSGMParams ( VPIPayload  payload,
VPIOpticalFlowDenseSGMParams sgmParams 
)

#include </opt/nvidia/vpi3/include/vpi/algo/OpticalFlowDense.h>

Retrieves the semi-global matching parameters set up in the Dense Optical Flow payload.

Parameters
[in]payloadPayload created by vpiCreateOpticalFlowDense.
  • Payload must be using the OFA backend.
[out]sgmParamsStructure where parameters will be written to.
  • Must not be NULL.
Return values
VPI_ERROR_INVALID_PAYLOAD_TYPEpayload is invalid.
VPI_ERROR_INVALID_ARGUMENTsgmParams is NULL.
VPI_ERROR_INVALID_OPERATIONpayload was not created for OFA dense optical flow.
VPI_SUCCESSOperation executed successfully.

◆ vpiOpticalFlowDenseSetSGMParams()

VPIStatus vpiOpticalFlowDenseSetSGMParams ( VPIPayload  payload,
const VPIOpticalFlowDenseSGMParams sgmParams 
)

#include </opt/nvidia/vpi3/include/vpi/algo/OpticalFlowDense.h>

Sets the semi-global matching parameters to be used by the Dense Optical Flow operations with the given payload.

The parameters will be only effective on future dense optical flow operations on the given payload. Already submitted operations won't be affected.

Parameters
[in]payloadPayload created by vpiCreateOpticalFlowDense.
  • Payload must be using the OFA backend.
[in]sgmParamsSGM parameters to be used by future dense optical flow submissions with given payload.
  • Must not be NULL.
Return values
VPI_ERROR_INVALID_PAYLOAD_TYPEpayload is invalid.
VPI_ERROR_INVALID_ARGUMENTsgmParams is NULL.
VPI_ERROR_INVALID_OPERATIONpayload was not created for OFA dense optical flow.
VPI_SUCCESSOperation executed successfully.