Skip to content

dnn_DetectionModel

Deep neural networksclassOpenCV 5.0.0
import { dnn_DetectionModel } from '@banou/opencv-wasm'

Use after await initOpenCV(). See the initialization and named imports guide.

ARGUMENTSConstructor or factory
CLASSdnn_DetectionModel
RETURN TYPEOwned native handle
Call structure. A void return can still write to destination arguments. The parameter descriptions define inputs, outputs and ownership.

Native object: release it with using or delete(). Factories can return null; check before calling methods. Inherits dnn_Model.

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. For DetectionModel SSD, Faster R-CNN, YOLO topologies are supported.

Constructors and members

static new

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

new(model: EmbindString, config: EmbindString): dnn_DetectionModel;
2 available overloads
new(network: EmbindString): dnn_DetectionModel;
new(model: EmbindString, config: EmbindString): dnn_DetectionModel;
network

Net object.

model

Binary file contains trained weights.

config

Text file contains network configuration.

Returns

The dnn_DetectionModel result.

static from1

Create an owned dnn_DetectionModel instance with the supplied configuration.

This class represents high-level API for object detection networks.

from1(_0: dnn_Net): dnn_DetectionModel | null;
_0

0 argument (dnn_Net).

Returns

The dnn_DetectionModel | null result.

clone

Create another handle to the same native object. This retains the object without copying its pixels or algorithm state; dispose both handles separately.

clone(): this;
Returns

The this result.

setNmsAcrossClasses

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.

setNmsAcrossClasses(value: boolean): dnn_DetectionModel;
value

The new value for nmsAcrossClasses

Returns

The dnn_DetectionModel result.

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

getNmsAcrossClasses(): boolean;
Returns

The boolean result.

detect

Given the input frame, create input blob, run net and return result detections.

detect(frame: Mat, classIds: IntVector, confidences: FloatVector, boxes: RectVector, confThreshold: number, nmsThreshold: number): void;
3 available overloads
detect(frame: Mat, classIds: IntVector, confidences: FloatVector, boxes: RectVector): void;
detect(frame: Mat, classIds: IntVector, confidences: FloatVector, boxes: RectVector, confThreshold: number): void;
detect(frame: Mat, classIds: IntVector, confidences: FloatVector, boxes: RectVector, confThreshold: number, nmsThreshold: number): void;
frame

The input image.

classIds

Output destination, filled by the native operation. Class indexes in result detection.

confidences

Output destination, filled by the native operation. A set of corresponding confidences.

boxes

Output destination, filled by the native operation. A set of bounding boxes.

confThreshold

A threshold used to filter boxes by confidences.

nmsThreshold

A threshold used in non maximum suppression.

These signatures describe this package. Upstream documentation can mention optional backends that are absent from this build. Check runtime compatibility before choosing a backend or file format.