VPI - Vision Programming Interface

2.0 Release - Developer Preview

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, 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. 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,
VPIOpticalFlowQuality  quality,
VPIPayload payload 
)

#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.
  • Must be >= 0.
[in]inputFmtFormat of current and previous image.
[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 or height 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 <vpi/algo/OpticalFlowDense.h>

Runs dense Optical Flow on two frames.

Outputs motion vectors for every 4x4 pixel block in the input image.

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]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.
  • On NVENC, dimensions must be 1/4 of curImg.
  • 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_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.