VPI - Vision Programming Interface

2.3 Release

Dense Optical Flow

Algorithm used to estimate the motion vectors from previous image to current image. 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...
 

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.

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/vpi2/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.
[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/vpi2/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/vpi2/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 cuurPyr 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.