Class DetectionModel
- Namespace
- OpenCvSharp.Dnn
- Assembly
- OpenCvSharp.dll
This class represents high-level API for object detection networks. DetectionModel allows to set params for preprocessing input image. DetectionModel creates net from file with trained weights and config, sets preprocessing input, runs forward pass and return result detections.
public class DetectionModel : Model, IDisposable
- Inheritance
-
DetectionModel
- Implements
- Inherited Members
Constructors
DetectionModel(Net)
Create model from deep learning network.
public DetectionModel(Net network)
Parameters
networkNetNet object.
DetectionModel(string, string?)
Create detection model from network represented in one of the supported formats. An order of @p model and @p config arguments does not matter.
public DetectionModel(string model, string? config = null)
Parameters
modelstringBinary file contains trained weights.
configstringText file contains network configuration.
Methods
Detect(InputArray, out int[], out float[], out Rect[], float, float)
Given the @p input frame, create input blob, run net and return result detections.
public void Detect(InputArray frame, out int[] classIds, out float[] confidences, out Rect[] boxes, float confThreshold = 0.5, float nmsThreshold = 0)
Parameters
frameInputArrayThe input image.
classIdsint[]Class indexes in result detection.
confidencesfloat[]A set of corresponding confidences.
boxesRect[]A set of bounding boxes.
confThresholdfloatA threshold used to filter boxes by confidences.
nmsThresholdfloatA threshold used in non maximum suppression.
GetNmsAcrossClasses()
Getter for nmsAcrossClasses. This variable defaults to false, such that when non max suppression is used during the detect() function, it will do so only per-class.
public bool GetNmsAcrossClasses()
Returns
- bool
true if nms is performed across classes.
SetNmsAcrossClasses(bool)
nmsAcrossClasses defaults to false, such that when non max suppression is used during the detect() function, it will do so per-class. This function allows you to toggle this behaviour.
public void SetNmsAcrossClasses(bool value)
Parameters
valueboolThe new value for nmsAcrossClasses.