Non-maximum suppression#
Set non-maximum values in a sliding window to zero.
NMS applies a sliding window non-maximum suppression algorithm to a tile. For each pixel, an NxN surrounding window is searched. If the pixel is the maximum in the window, it is passed through to the output. Otherwise, the corresponding output pixel is set to zero. If the pixel is tied for maximum with another pixel in the window, it is selected if it is closer to the bottom-right.
Due to the use of a sliding window, the output may be surprising compared to a grid-based NMS algorithm. For example a constant tile such as I(y,x) = k or a gradient tile such as I(y,x) = x will both have zero response.
Each pixel in the output has NxN support in the input, meaning the output will be N-1 pixels less than the input in both width and height and offset by N/2. For example with 5x5, the output at x=0, y=0 is the NMS response of input pixel x=2, y=2, and the output width/height are both 4 pixels less than the specified input.
Macros#
- PVAAPL_NMS_SCRATCH_SIZE
Determine bytes needed for a scratch buffer with NMS.
Functions#
- void pvaAplExecNms3x3S32(PvaAplNms3x3S32 *handle)
Execute 3x3 NMS algorithm with a given handle.
- void pvaAplExecNms3x3S32Vpu(PvaAplNms3x3S32 *handle)
Execute 3x3 NMS algorithm with a given handle.
- void pvaAplExecNms5x5S32(PvaAplNms5x5S32 *handle)
Execute 5x5 NMS algorithm with a given handle.
- void pvaAplExecNms5x5S32Vpu(PvaAplNms5x5S32 *handle)
Execute 5x5 NMS algorithm with a given handle.
- void pvaAplInitNms3x3S32(PvaAplNms3x3S32 *handle, int32_t *input, int32_t width, int32_t height, int32_t inputLinePitch, int32_t outputLinePitch, int32_t *output, int32_t *cbStart, int32_t cbSize, void *scratch)
Initialize the 3x3 Non-Maximum Suppression algorithm parameters.
- void pvaAplInitNms3x3S32Vpu(PvaAplNms3x3S32 *handle, int32_t *input, int32_t width, int32_t height, int32_t inputLinePitch, int32_t outputLinePitch, int32_t *output, int32_t *cbStart, int32_t cbSize, void *scratch)
Initialize the 3x3 Non-Maximum Suppression algorithm parameters.
- void pvaAplInitNms5x5S32(PvaAplNms5x5S32 *handle, int32_t *input, int32_t width, int32_t height, int32_t inputLinePitch, int32_t outputLinePitch, int32_t *output, int32_t *cbStart, int32_t cbSize, void *scratch)
Initialize the 5x5 Non-Maximum Suppression algorithm parameter.
- void pvaAplInitNms5x5S32Vpu(PvaAplNms5x5S32 *handle, int32_t *input, int32_t width, int32_t height, int32_t inputLinePitch, int32_t outputLinePitch, int32_t *output, int32_t *cbStart, int32_t cbSize, void *scratch)
Initialize the 5x5 Non-Maximum Suppression algorithm parameter.
- void pvaAplUpdateNms3x3S32(PvaAplNms3x3S32 *handle, int32_t *input, int32_t *output)
Update the input/output buffer pointers and input image size for the Non-Maximum Suppression algorithm.
- void pvaAplUpdateNms3x3S32Vpu(PvaAplNms3x3S32 *handle, int32_t *input, int32_t *output)
Update the input/output buffer pointers and input image size for the Non-Maximum Suppression algorithm.
- void pvaAplUpdateNms5x5S32(PvaAplNms5x5S32 *handle, int32_t *input, int32_t *output)
Update the input/output buffer pointers and input image size for the Non-Maximum Suppression algorithm.
- void pvaAplUpdateNms5x5S32Vpu(PvaAplNms5x5S32 *handle, int32_t *input, int32_t *output)
Update the input/output buffer pointers and input image size for the Non-Maximum Suppression algorithm.
Functions#
-
inline void pvaAplExecNms3x3S32(PvaAplNms3x3S32 *handle)#
Execute 3x3 NMS algorithm with a given handle.
- Parameters:
handle – Pointer to the NMS algorithm handle.
-
void pvaAplExecNms3x3S32Vpu(PvaAplNms3x3S32 *handle)#
Execute 3x3 NMS algorithm with a given handle.
This variant ensures synchronous execution on VPU, even on platforms supporting asynchronous acceleration. Do not call pvaAplWait() when using this variant.
- Parameters:
handle – Pointer to the NMS algorithm handle.
-
inline void pvaAplExecNms5x5S32(PvaAplNms5x5S32 *handle)#
Execute 5x5 NMS algorithm with a given handle.
- Parameters:
handle – Pointer to the NMS algorithm handle.
-
void pvaAplExecNms5x5S32Vpu(PvaAplNms5x5S32 *handle)#
Execute 5x5 NMS algorithm with a given handle.
This variant ensures synchronous execution on VPU, even on platforms supporting asynchronous acceleration. Do not call pvaAplWait() when using this variant.
- Parameters:
handle – Pointer to the NMS algorithm handle.
- inline void pvaAplInitNms3x3S32(
- PvaAplNms3x3S32 *handle,
- int32_t *input,
- int32_t width,
- int32_t height,
- int32_t inputLinePitch,
- int32_t outputLinePitch,
- int32_t *output,
- int32_t *cbStart,
- int32_t cbSize,
- void *scratch,
Initialize the 3x3 Non-Maximum Suppression algorithm parameters.
- Parameters:
handle – Pointer to the algorithm handle.
input – Pointer to the input buffer in int32_t pixel format.
width – Input image width in pixels.
height – Input image height in pixels.
inputLinePitch – Input buffer line pitch in pixels.
outputLinePitch – Output buffer line pitch in pixels. Must be >=
width
- 2.output – Pointer to the NMS output buffer in int32_t format. Output is written in blocks of 16 rows. The buffer must be large enough to hold
height
- 2 rows, rounded up to a multiple of 16. For example if input height is 136, the buffer should be large enough to hold 144 rows. Only the firstheight
- 2 rows will contain valid data.cbStart – Start address of the input circular buffer.
cbSize – Size of the input circular buffer in bytes.
scratch – Scratch buffer. Size needed is given by PVAAPL_NMS_SCRATCH_SIZE.
- void pvaAplInitNms3x3S32Vpu(
- PvaAplNms3x3S32 *handle,
- int32_t *input,
- int32_t width,
- int32_t height,
- int32_t inputLinePitch,
- int32_t outputLinePitch,
- int32_t *output,
- int32_t *cbStart,
- int32_t cbSize,
- void *scratch,
Initialize the 3x3 Non-Maximum Suppression algorithm parameters.
This variant ensures synchronous execution on VPU, even on platforms supporting asynchronous acceleration.
- Parameters:
handle – Pointer to the algorithm handle.
input – Pointer to the input buffer in int32_t pixel format.
width – Input image width in pixels.
height – Input image height in pixels.
inputLinePitch – Input buffer line pitch in pixels.
outputLinePitch – Output buffer line pitch in pixels. Must be >=
width
- 2.output – Pointer to the NMS output buffer in int32_t format. Output is written in blocks of 16 rows. The buffer must be large enough to hold
height
- 2 rows, rounded up to a multiple of 16. For example if input height is 136, the buffer should be large enough to hold 144 rows. Only the firstheight
- 2 rows will contain valid data.cbStart – Start address of the input circular buffer.
cbSize – Size of the input circular buffer in bytes.
scratch – Scratch buffer. Size needed is given by PVAAPL_NMS_SCRATCH_SIZE.
- inline void pvaAplInitNms5x5S32(
- PvaAplNms5x5S32 *handle,
- int32_t *input,
- int32_t width,
- int32_t height,
- int32_t inputLinePitch,
- int32_t outputLinePitch,
- int32_t *output,
- int32_t *cbStart,
- int32_t cbSize,
- void *scratch,
Initialize the 5x5 Non-Maximum Suppression algorithm parameter.
- Parameters:
handle – Pointer to the algorithm handle.
input – Pointer to the input buffer in int32_t pixel format.
width – Input image width in pixels.
height – Input image height in pixels.
inputLinePitch – Input buffer line pitch in pixels.
outputLinePitch – Output buffer line pitch in pixels. Must be >=
width
- 4.output – Pointer to the NMS output buffer in int32_t format. Output is written in blocks of 16 rows. The buffer must be large enough to hold
height
- 4 rows, rounded up to a multiple of 16. For example if input height is 136, the buffer should be large enough to hold 144 rows. Only the firstheight
- 4 rows will contain valid data.cbStart – Start address of the input circular buffer.
cbSize – Size of the input circular buffer in bytes.
scratch – Scratch buffer. Size needed is given by PVAAPL_NMS_SCRATCH_SIZE.
- void pvaAplInitNms5x5S32Vpu(
- PvaAplNms5x5S32 *handle,
- int32_t *input,
- int32_t width,
- int32_t height,
- int32_t inputLinePitch,
- int32_t outputLinePitch,
- int32_t *output,
- int32_t *cbStart,
- int32_t cbSize,
- void *scratch,
Initialize the 5x5 Non-Maximum Suppression algorithm parameter.
This variant ensures synchronous execution on VPU, even on platforms supporting asynchronous acceleration.
- Parameters:
handle – Pointer to the algorithm handle.
input – Pointer to the input buffer in int32_t pixel format.
width – Input image width in pixels.
height – Input image height in pixels.
inputLinePitch – Input buffer line pitch in pixels.
outputLinePitch – Output buffer line pitch in pixels. Must be >=
width
- 4.output – Pointer to the NMS output buffer in int32_t format. Output is written in blocks of 16 rows. The buffer must be large enough to hold
height
- 4 rows, rounded up to a multiple of 16. For example if input height is 136, the buffer should be large enough to hold 144 rows. Only the firstheight
- 4 rows will contain valid data.cbStart – Start address of the input circular buffer.
cbSize – Size of the input circular buffer in bytes.
scratch – Scratch buffer. Size needed is given by PVAAPL_NMS_SCRATCH_SIZE.
- inline void pvaAplUpdateNms3x3S32(
- PvaAplNms3x3S32 *handle,
- int32_t *input,
- int32_t *output,
Update the input/output buffer pointers and input image size for the Non-Maximum Suppression algorithm.
- Parameters:
handle – Pointer to the algorithm handle.
input – Pointer to the input buffer
output – Pointer to the NMS output buffer in int32_t format.
- void pvaAplUpdateNms3x3S32Vpu(
- PvaAplNms3x3S32 *handle,
- int32_t *input,
- int32_t *output,
Update the input/output buffer pointers and input image size for the Non-Maximum Suppression algorithm.
This variant ensures synchronous execution on VPU, even on platforms supporting asynchronous acceleration.
- Parameters:
handle – Pointer to the algorithm handle.
input – Pointer to the input buffer
output – Pointer to the NMS output buffer in int32_t format.
- inline void pvaAplUpdateNms5x5S32(
- PvaAplNms5x5S32 *handle,
- int32_t *input,
- int32_t *output,
Update the input/output buffer pointers and input image size for the Non-Maximum Suppression algorithm.
- Parameters:
handle – Pointer to the algorithm handle.
input – Pointer to the input buffer
output – Pointer to the NMS output buffer in int32_t format.
- void pvaAplUpdateNms5x5S32Vpu(
- PvaAplNms5x5S32 *handle,
- int32_t *input,
- int32_t *output,
Update the input/output buffer pointers and input image size for the Non-Maximum Suppression algorithm.
This variant ensures synchronous execution on VPU, even on platforms supporting asynchronous acceleration.
- Parameters:
handle – Pointer to the algorithm handle.
input – Pointer to the input buffer
output – Pointer to the NMS output buffer in int32_t format.