Skip to content

dnn_SegmentationModel

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

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

ARGUMENTSConstructor or factory
CLASSdnn_SegmentationModel
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 segmentation models

SegmentationModel allows to set params for preprocessing input image. SegmentationModel creates net from file with trained weights and config, sets preprocessing input, runs forward pass and returns the class prediction for each pixel.

Constructors and members

static new

Create segmentation 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_SegmentationModel;
2 available overloads
new(network: EmbindString): dnn_SegmentationModel;
new(model: EmbindString, config: EmbindString): dnn_SegmentationModel;
network

Net object.

model

Binary file contains trained weights.

config

Text file contains network configuration.

Returns

The dnn_SegmentationModel result.

static from1

Create an owned dnn_SegmentationModel instance with the supplied configuration.

This class represents high-level API for segmentation models

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

0 argument (dnn_Net).

Returns

The dnn_SegmentationModel | 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.

segment

Given the input frame, create input blob, run net

segment(frame: Mat, mask: Mat): void;
frame

The input image.

mask

Output destination, filled by the native operation. Allocated class prediction for each pixel

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.