API reference
API reference
Select your platform
No SDKs available
No versions available

GpuNms Class

GPU-accelerated Non-Maximum Suppression utilities.
Uses a compute shader to filter and compact detections so that only a small set of results needs to be read back to the CPU. See ComputeShader and ComputeBuffer for the underlying Unity APIs.

Constructors & Destructors

GpuNms
( ComputeShader shader )
Runs NMS on the GPU and returns kept indices for the provided CPU lists of boxes and scores.
Use when detection results are already on the CPU. See also RunNmsAsync(UnityEngine.ComputeBuffer,UnityEngine.ComputeBuffer,UnityEngine.ComputeBuffer,int,float,float,int,float,float) for the zero-copy GPU gather path.
Zero-copy GPU gather: runs NMS and writes compact detections directly on the GPU, then reads back only the first maxKeep results.
Use when model outputs are on the GPU (Compute backend).
Parameters
boxesBuffer
GPU buffer of float4 boxes (xywh).
scoresBuffer
GPU buffer of scores.
classIdsBuffer
GPU buffer of class IDs.
count
Number of candidate boxes.
iouThreshold
IoU overlap threshold for suppression.
minConfidence
Minimum score to consider a box.
maxKeep
Maximum number of kept detections.
scaleX
Scale from model input width to source texture width.
scaleY
Scale from model input height to source texture height.