VPI - Vision Programming Interface

2.0 Release

Histogram of Oriented Gradients

Extracts Histogram of Oriented Gradients features from input image. More...

Functions

VPIStatus vpiCreateExtractHOGFeatures (uint64_t backends, int32_t width, int32_t height, int32_t features, int32_t cellSize, int32_t numOrientations, int32_t *outNumFeatures, VPIPayload *payload)
 Create a payload for the non-batch version of HOG algorithm. More...
 
VPIStatus vpiCreateExtractHOGFeaturesBatch (uint64_t backends, int32_t maxBatchWidth, int32_t maxBatchHeight, int32_t imgWidth, int32_t imgHeight, int32_t features, int32_t cellSize, int32_t numOrientations, int32_t *outNumFeatures, VPIPayload *payload)
 Create a payload for the batch version of HOG algorithm. More...
 
VPIStatus vpiSubmitExtractHOGFeatures (VPIStream stream, uint64_t backend, VPIPayload payload, VPIImage input, VPIImage *outFeatures, int32_t numFeatures)
 Submits a HOG operation to the stream. More...
 

HOG flags

Defines what features will be returned.

#define VPI_HOG_CONTRAST_SENSITIVE   0x01
 Return contrast sensitive features.
 
#define VPI_HOG_CONTRAST_INSENSITIVE   0x02
 Return contrast insensitive features.
 
#define VPI_HOG_TEXTURE   0x04
 Return texture-related features.
 
#define VPI_HOG_ALL_FEATURES   (VPI_HOG_CONTRAST_SENSITIVE | VPI_HOG_CONTRAST_INSENSITIVE | VPI_HOG_TEXTURE)
 Helper flag to return all features.
 

Detailed Description

Extracts Histogram of Oriented Gradients features from input image.

Function Documentation

◆ vpiCreateExtractHOGFeatures()

VPIStatus vpiCreateExtractHOGFeatures ( uint64_t  backends,
int32_t  width,
int32_t  height,
int32_t  features,
int32_t  cellSize,
int32_t  numOrientations,
int32_t *  outNumFeatures,
VPIPayload payload 
)

#include </opt/nvidia/vpi2/include/vpi/experimental/HOG.h>

Create a payload for the non-batch version of HOG algorithm.

Parameters
[in]backendsVPI backends that are eligible to execute the algorithm.
[in]width,heightDimensions of the input image to be used.
  • Must be >= 0.
[in]featuresFlags to specify what features will be returned.
[in]cellSizeCell size, typically 8 or 16 for 8x8 and 16x16 cells respectively.
  • Must be >=2 and <= 32 and power of two.
[in]numOrientationsNumber of orientations used. This is typically 18.
  • Must be between 4 and 18.
[out]outNumFeaturesReceives the number of features that will be returned. Pass NULL if not needed.
[out]payloadPointer to the payload variable that receives the created handle.
Return values
VPI_ERROR_INVALID_ARGUMENTpayload handle is NULL.
VPI_ERROR_INVALID_ARGUMENTwidth or height outside valid range.
VPI_ERROR_NOT_IMPLEMENTEDHOG is not implemented for given backend.
VPI_ERROR_INVALID_CONTEXTCurrent context is destroyed.
VPI_ERROR_OUT_OF_MEMORYCannot allocate required resources.
VPI_SUCCESSOperation executed successfully.

◆ vpiCreateExtractHOGFeaturesBatch()

VPIStatus vpiCreateExtractHOGFeaturesBatch ( uint64_t  backends,
int32_t  maxBatchWidth,
int32_t  maxBatchHeight,
int32_t  imgWidth,
int32_t  imgHeight,
int32_t  features,
int32_t  cellSize,
int32_t  numOrientations,
int32_t *  outNumFeatures,
VPIPayload payload 
)

#include </opt/nvidia/vpi2/include/vpi/experimental/HOG.h>

Create a payload for the batch version of HOG algorithm.

The input images are assumed to be laid out in memory as a 2D matrix of images. All images must have the same dimensions.

Parameters
[in]backendsVPI backends that are eligible to execute the algorithm.
[in]maxBatchWidth,maxBatchHeightMaximum number of images horizontally and vertically, respectively.
  • Must be >= 0.
[in]imgWidth,imgHeightDimensions each of the batch images.
  • Must be >= 0.
  • imgWidth and imgHeight must be multiple of cell width and height respectively.
[in]featuresFlags to specify which features will be returned.
[in]cellSizeCell size, typically 8 or 16 for 8x8 and 16x16 cells respectively.
  • Must be >=2 and <= 32 and power of two.
[in]numOrientationsNumber of orientations used. This is typically 18.
  • Must be between 4 and 18.
[out]outNumFeaturesReceives the number of features that will be returned. Pass NULL if not needed.
[out]payloadPointer to a payload handle that will receive the allocated payload.
Return values
VPI_ERROR_INVALID_ARGUMENTpayload handle is NULL.
VPI_ERROR_INVALID_ARGUMENTmaxBatchWidth or maxBatchHeight outside valid range.
VPI_ERROR_INVALID_ARGUMENTimgWidth or imgHeight outside valid range.
VPI_ERROR_INVALID_ARGUMENTInvalid features.
VPI_ERROR_INVALID_ARGUMENTcellSize or numOrientations outside valid range.
VPI_ERROR_INVALID_ARGUMENTimgWidth must be a multiple of cell width.
VPI_ERROR_INVALID_ARGUMENTimgHeight must be a multiple of cell height.
VPI_ERROR_INVALID_ARGUMENTbackends refers to an invalid backend.
VPI_ERROR_NOT_IMPLEMENTEDHOG is not implemented for given backend.
VPI_ERROR_INVALID_CONTEXTCurrent context is destroyed.
VPI_ERROR_OUT_OF_MEMORYCannot allocate required resources.
VPI_SUCCESSOperation executed successfully.

◆ vpiSubmitExtractHOGFeatures()

VPIStatus vpiSubmitExtractHOGFeatures ( VPIStream  stream,
uint64_t  backend,
VPIPayload  payload,
VPIImage  input,
VPIImage outFeatures,
int32_t  numFeatures 
)

#include </opt/nvidia/vpi2/include/vpi/experimental/HOG.h>

Submits a HOG operation to the stream.

It handles both batch and non-batch payloads.

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 to be submitted along the other parameters.
[in]inputIf using a non batch payload, this is the input image to be processed.
  • Must not be NULL.
  • Its dimensions must match what was passed to vpiCreateExtractHOGFeatures.
  • If using a batch payload, the image dimensions must be a multiple of (imgWidth,imgHeight), and it must be at most (imgWidth*maxBatchWidth, imgHeight*maxBatchHeight).
  • Image must have enabled the backends that will execute the algorithm.
[out]outFeaturesPointer to an array of images that will receive the features.
  • Must not be NULL.
  • The dimensions of each image must be (input.width / cellSize, input.height / cellSize).
  • In case of batch processing, the output features position in the 2D matrix be the same position of the corresponding input image.
  • All images must have same format.
  • All image must have enabled the backends that will execute the algorithm.
[in]numFeaturesNumber of images in the output array. Must be between 1 and 32.
Return values
VPI_ERROR_INVALID_ARGUMENTstream is NULL.
VPI_ERROR_INVALID_ARGUMENTinput or outFeatures are NULL.
VPI_ERROR_INVALID_ARGUMENTpayload is not generated using vpiCreateExtractHOGFeatures.
VPI_ERROR_INVALID_ARGUMENTnumFeatures outside valid range.
VPI_ERROR_INVALID_ARGUMENTBatch input width must be a multiple of configured input width.
VPI_ERROR_INVALID_ARGUMENTBatch input height must be a multiple of configured input height.
VPI_ERROR_INVALID_ARGUMENToutFeatures must all have the same format.
VPI_ERROR_INVALID_PAYLOAD_TYPEpayload is invalid.
VPI_ERROR_INVALID_OPERATIONThe needed backends aren't enabled in stream, input or outFeatures.
VPI_SUCCESSOperation executed successfully.