Table of Contents

Class ClassificationModel

Namespace
OpenCvSharp.Dnn
Assembly
OpenCvSharp.dll

This class represents high-level API for classification models. ClassificationModel allows to set params for preprocessing input image. ClassificationModel creates net from file with trained weights and config, sets preprocessing input, runs forward pass and return top-1 prediction.

public class ClassificationModel : Model, IDisposable
Inheritance
ClassificationModel
Implements
Inherited Members

Constructors

ClassificationModel(Net)

Create model from deep learning network.

public ClassificationModel(Net network)

Parameters

network Net

Net object.

ClassificationModel(string, string?)

Create classification model from network represented in one of the supported formats. An order of @p model and @p config arguments does not matter.

public ClassificationModel(string model, string? config = null)

Parameters

model string

Binary file contains trained weights.

config string

Text file contains network configuration.

Methods

Classify(InputArray, out int, out float)

Given the @p input frame, create input blob, run net and return top-1 prediction.

public void Classify(InputArray frame, out int classId, out float conf)

Parameters

frame InputArray

The input image.

classId int

Top-1 predicted class id.

conf float

Top-1 prediction confidence.

GetEnableSoftmaxPostProcessing()

Get enable/disable softmax post processing option.

public bool GetEnableSoftmaxPostProcessing()

Returns

bool

true if softmax post processing is enabled.

SetEnableSoftmaxPostProcessing(bool)

Set enable/disable softmax post processing option.

public void SetEnableSoftmaxPostProcessing(bool enable)

Parameters

enable bool

Set enable softmax post processing.