MinMaxLoc

group NVCV_C_ALGORITHM_MINMAXLOC

Functions

NVCVStatus cvcudaMinMaxLocCreate(NVCVOperatorHandle *handle)

Constructs an instance of the MinMaxLoc operator.

Parameters:

handle[out] Where the image instance handle will be written to.

  • Must not be NULL.

Return values:
  • NVCV_ERROR_INVALID_ARGUMENT – Handle is null.

  • NVCV_ERROR_OUT_OF_MEMORY – Not enough memory to create the operator.

  • NVCV_SUCCESS – Operation executed successfully.

NVCVStatus cvcudaMinMaxLocSubmit(NVCVOperatorHandle handle, cudaStream_t stream, NVCVTensorHandle in, NVCVTensorHandle minVal, NVCVTensorHandle minLoc, NVCVTensorHandle numMin, NVCVTensorHandle maxVal, NVCVTensorHandle maxLoc, NVCVTensorHandle numMax)

Executes the MinMaxLoc operation on the given cuda stream. This operation does not wait for completion.

Limitations:

Input: Data Layout: [HWC, NHWC, CHW, NCHW] Channels: [1]

Data Type

Allowed

8bit Unsigned

Yes

8bit Signed

Yes

16bit Unsigned

Yes

16bit Signed

Yes

32bit Unsigned

Yes

32bit Signed

Yes

32bit Float

Yes

64bit Float

Yes

Note

The MinMaxLoc operation does not guarantee deterministic output. The order of output minimum or maximum locations found is in no particular order and might differ in different runs.

Parameters:
  • handle[in] Handle to the operator.

    • Must not be NULL.

  • stream[in] Handle to a valid CUDA stream.

  • in[in] Input tensor. The expected layout is [HWC] or [NHWC] or [CHW] or [NCHW], where N is the number of samples, i.e. images with height H and width W and channels C, inside the tensor.

  • minVal[out] Output tensor to store minimum values found in the input tensor. The expected layout is [N] or [NC], meaning rank-1 or rank-2 tensor with first dimension as number of samples N, and a potential last dimension C with number of channels.

    • It must have the same number of samples as input tensor.

    • It must have one element per sample, i.e. number of channels must be 1 in a [NC] tensor.

    • It must have data type S32/U32/F32/F64: for input data type S8/S16/S32 use S32; for U8/U16/U32 use U32; for all other data types use same data type as input tensor.

    • It may be NULL to disregard finding minimum values and locations.

  • minLoc[out] Output tensor to store minimum locations found in the input tensor. The expected layout is [NM] or [NMC], meaning rank-2 or rank-3 tensor with first dimension as number of samples N, second dimension as maximum number of locations M to be found, and a potential last dimension C with number of channels.

    • It must have the same number of samples as input tensor.

    • It must have 2S32 data type to store (x, y) sample locations, i.e. (x) coordinate on the width W and (y) coordinate on the height H of a sample image.

    • It must have a number of elements M equal to the maximum allowed number of locations to be found per sample image (see below).

    • It must be NULL if minVal is NULL (see above).

  • numMin[out] Output tensor to store the number of minimum locations found in the input tensor. The expected layout is [N] or [NC], meaning rank-1 or rank-2 tensor with first dimension as number of samples N, and a potential last dimension C with number of channels.

    • It must have the same number of samples as input tensor.

    • It must have S32 data type to store number of minima found.

    • It must have one element per sample, i.e. number of channels must be 1 in a [NC] tensor.

    • It must be NULL if minVal is NULL (see above).

  • maxVal[out] Output tensor to store maximum values found in the input tensor. The expected layout is [N] or [NC], meaning rank-1 or rank-2 tensor with first dimension as number of samples N, and a potential last dimension C with number of channels.

    • It must have the same number of samples as input tensor.

    • It must have one element per sample, i.e. number of channels must be 1 in a [NC] tensor.

    • It must have data type S32/U32/F32/F64: for input data type S8/S16/S32 use S32; for U8/U16/U32 use U32; for all other data types use same data type as input tensor.

    • It may be NULL to disregard finding maximum values and locations.

  • maxLoc[out] Output tensor to store maximum locations found in the input tensor. The expected layout is [NM] or [NMC], meaning rank-2 or rank-3 tensor with first dimension as number of samples N, second dimension as maximum number of locations M to be found, and a potential last dimension C with number of channels.

    • It must have the same number of samples as input tensor.

    • It must have 2S32 data type to store (x, y) sample locations, i.e. (x) coordinate on the width W and (y) coordinate on the height H of a sample image.

    • It must have a number of elements M equal to the maximum allowed number of locations to be found per sample image (see below).

    • It must be NULL if maxVal is NULL (see above).

  • numMax[out] Output tensor to store the number of maximum locations found in the input tensor. The expected layout is [N] or [NC], meaning rank-1 or rank-2 tensor with first dimension as number of samples N, and a potential last dimension C with number of channels.

    • It must have the same number of samples as input tensor.

    • It must have S32 data type to store number of maxima found.

    • It must have one element per sample, i.e. number of channels must be 1 in a [NC] tensor.

    • It must be NULL if maxVal is NULL (see above).

Return values:
  • NVCV_ERROR_INVALID_ARGUMENT – Some parameter is outside valid range.

  • NVCV_ERROR_INTERNAL – Internal error in the operator, invalid types passed in.

  • NVCV_SUCCESS – Operation executed successfully.

NVCVStatus cvcudaMinMaxLocVarShapeSubmit(NVCVOperatorHandle handle, cudaStream_t stream, NVCVImageBatchHandle in, NVCVTensorHandle minVal, NVCVTensorHandle minLoc, NVCVTensorHandle numMin, NVCVTensorHandle maxVal, NVCVTensorHandle maxLoc, NVCVTensorHandle numMax)

Executes the MinMaxLoc operation on a batch of images.

Apart from input image batch, all parameters are the same as cvcudaMinMaxLocSubmit.

Parameters:

in[in] Input image batch.