VPI - Vision Programming Interface

3.0 Release

Template Matching Algorithm

Runs the template matching algorithm with template image over the searched image. More...

Enumerations

enum  VPITemplateMatchingMethod
 Define method to calculate the template matching score. More...
 

Functions

VPIStatus vpiCreateTemplateMatching (uint64_t backends, int32_t imageWidth, int32_t imageHeight, VPIPayload *payload)
 Creates payload for vpiSubmitTemplateMatching. More...
 
VPIStatus vpiTemplateMatchingSetSourceImage (VPIStream stream, uint64_t backend, VPIPayload payload, VPIImage srcImage)
 Set the source image. More...
 
VPIStatus vpiTemplateMatchingSetTemplateImage (VPIStream stream, uint64_t backend, VPIPayload payload, VPIImage templImage, VPIImage mask)
 Set the template image. More...
 
VPIStatus vpiSubmitTemplateMatching (VPIStream stream, uint64_t backend, VPIPayload payload, VPIImage output, VPITemplateMatchingMethod method)
 Runs the template matching algorithm with provided template. More...
 

Detailed Description

Runs the template matching algorithm with template image over the searched image.

Refer to Template Matching for more details and usage examples.

Enumeration Type Documentation

◆ VPITemplateMatchingMethod

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

Define method to calculate the template matching score.

Enumerator
VPI_TEMPLATE_MATCHING_NCC 

Normalized cross correlation.

Definition at line 195 of file TemplateMatching.h.

Function Documentation

◆ vpiCreateTemplateMatching()

VPIStatus vpiCreateTemplateMatching ( uint64_t  backends,
int32_t  imageWidth,
int32_t  imageHeight,
VPIPayload payload 
)

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

Creates payload for vpiSubmitTemplateMatching.

Attention
For this function to succeed, the below libraries must to be installed in the system:
  • libnppc.so.11
  • libnppial.so.11
  • libnppidei.so.11
  • libnppist.so.11
Parameters
[in]backendsVPI backends that are eligible to execute the algorithm.
[in]imageWidthSource image width.
[in]imageHeightSource image height.
[out]payloadPointer to the payload variable that receives the created handle.
Return values
VPI_ERROR_INVALID_ARGUMENTpayload is NULL.
VPI_ERROR_INVALID_ARGUMENTimageWidth and imageHeight outside valid range.
VPI_ERROR_INVALID_ARGUMENTbackends refers to an invalid backend.
VPI_ERROR_INVALID_OPERATIONBackend isn't enabled in current context.
VPI_ERROR_INVALID_OPERATIONRequired NPP libraries aren't installed in the system.
VPI_ERROR_NOT_IMPLEMENTEDAlgorithm is not supported by given backend.
VPI_ERROR_INVALID_CONTEXTCurrent context is destroyed.
VPI_ERROR_OUT_OF_MEMORYCannot allocate required resources.
VPI_SUCCESSOperation executed successfully.

◆ vpiTemplateMatchingSetSourceImage()

VPIStatus vpiTemplateMatchingSetSourceImage ( VPIStream  stream,
uint64_t  backend,
VPIPayload  payload,
VPIImage  srcImage 
)

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

Set the source image.

Parameters
[in]streamA stream handle where the operation will be queued into.
  • Must not be NULL.
  • Stream must have enabled the backends that will execute the algorithm.
[in]backendBackend that will execute the algorithm.
[in]payloadPointer to the payload variable that receives the created handle.
[in]srcImageSource image where the template image will be searching on.
Return values
VPI_ERROR_INVALID_ARGUMENTpayload is NULL.
VPI_ERROR_INVALID_ARGUMENTsrcImage is NULL.
VPI_ERROR_INVALID_ARGUMENTsrcImage resolution does not match with the one specified in the vpiCreateTemplateMatching.
VPI_ERROR_INVALID_OPERATIONBackend isn't enabled in current context.
VPI_ERROR_INVALID_OPERATIONThe needed backends aren't enabled in srcImage.
VPI_ERROR_INVALID_CONTEXTCurrent context is destroyed.
VPI_ERROR_OUT_OF_MEMORYCannot allocate required resources.
VPI_SUCCESSOperation executed successfully.

◆ vpiTemplateMatchingSetTemplateImage()

VPIStatus vpiTemplateMatchingSetTemplateImage ( VPIStream  stream,
uint64_t  backend,
VPIPayload  payload,
VPIImage  templImage,
VPIImage  mask 
)

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

Set the template image.

Parameters
[in]streamA stream handle where the operation will be queued into.
  • Must not be NULL.
  • Stream must have enabled the backends that will execute the algorithm.
[in]backendBackend that will execute the algorithm.
[in]payloadPointer to the payload variable that receives the created handle.
[in]templImageTemplate image.
[in]maskMask used when calculating the template matching score.
  • Could be NULL if not needed.
  • Must have same dimension as the template image
  • The accepted image formats are:
    Format CPU CUDA
    VPI_IMAGE_FORMAT_U8 * *
Return values
VPI_ERROR_INVALID_ARGUMENTpayload is NULL.
VPI_ERROR_INVALID_ARGUMENTtemplImage is NULL.
VPI_ERROR_INVALID_ARGUMENTtemplImage resolution is greater than source image.
VPI_ERROR_INVALID_OPERATIONBackend isn't enabled in current context.
VPI_ERROR_INVALID_OPERATIONThe needed backends aren't enabled in templImage.
VPI_ERROR_INVALID_CONTEXTCurrent context is destroyed.
VPI_ERROR_OUT_OF_MEMORYCannot allocate required resources.
VPI_SUCCESSOperation executed successfully.

◆ vpiSubmitTemplateMatching()

VPIStatus vpiSubmitTemplateMatching ( VPIStream  stream,
uint64_t  backend,
VPIPayload  payload,
VPIImage  output,
VPITemplateMatchingMethod  method 
)

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

Runs the template matching algorithm with provided template.

Parameters
[in]streamA stream handle where the operation will be queued into.
  • Must not be NULL.
  • Stream must have enabled the backends that will execute the algorithm.
[in]backendBackend that will execute the algorithm.
[in]payloadPointer to the payload variable that receives the created handle.
[out]outputOutput image where the template matching score is written to.
  • Must not be NULL.
  • Assume the source image is with resolution WxH and template image is with resolution wxh, then the output image shall have resolution (W - w + 1) * (H - h + 1)
  • Image format has to be VPI_IMAGE_FORMAT_F32.
  • Image must have enabled the backends that will execute the algorithm.
[in]methodSpecify the method when calculating the template matching score.
Return values
VPI_ERROR_INVALID_ARGUMENTstream is NULL.
VPI_ERROR_INVALID_ARGUMENToutput is NULL.
VPI_ERROR_INVALID_ARGUMENTbackend is invalid or unknown.
VPI_ERROR_INVALID_IMAGE_FORMAToutput image format not supported.
VPI_ERROR_INVALID_OPERATIONBackend hardware is not available.
VPI_ERROR_INVALID_OPERATIONThe needed backends aren't enabled in stream and output.
VPI_ERROR_NOT_IMPLEMENTEDAlgorithm is not supported by given backend.
VPI_SUCCESSOperation executed successfully.