Table of Contents

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

network Net

Net 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

model string

Binary file contains trained weights.

config string

Text 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

frame InputArray

The input image.

classIds int[]

Class indexes in result detection.

confidences float[]

A set of corresponding confidences.

boxes Rect[]

A set of bounding boxes.

confThreshold float

A threshold used to filter boxes by confidences.

nmsThreshold float

A 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

value bool

The new value for nmsAcrossClasses.