Skip to content

dnn_Layer

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

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

ARGUMENTSConstructor or factory
CLASSdnn_Layer
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 Algorithm.

This interface class allows to build new Layers - are building blocks of networks.

Each class, derived from Layer, must implement forward() method to compute outputs. Also before using the new layer into networks you must register your layer by using one of dnnLayerFactory "LayerFactory" macros.

Constructors and members

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.

blobs

List of learned parameters must be stored here to allow read them by using Net::getParam().

blobs: MatVector;

name

Name of the layer instance, can be used for logging or other internal purposes.

set name(value: EmbindString);
2 available overloads
get name(): string;
set name(value: EmbindString);
value

value argument (EmbindString).

Returns

The string result.

type

Type name which was used for creating layer by layer factory.

set type(value: EmbindString);
2 available overloads
get type(): string;
set type(value: EmbindString);
value

value argument (EmbindString).

Returns

The string result.

preferableTarget

prefer target for layer forwarding

preferableTarget: number;

finalize

Computes and sets internal parameters according to inputs, outputs and blobs.

finalize(inputs: MatVector, outputs: MatVector): void;
inputs

vector of already allocated input blobs

outputs

Output destination, filled by the native operation. vector of already allocated output blobs

This method is called after network has allocated all memory for input and output blobs and before inferencing.

run

Allocates layer and computes output. deprecated: This method will be removed in the future release.

run(inputs: MatVector, outputs: MatVector, internals: MatVector): void;
inputs

inputs argument (MatVector).

outputs

Output destination, filled by the native operation. outputs argument (MatVector).

internals

Input/output value, modified by the native operation. internals argument (MatVector).

outputNameToIndex

FIXIT const Returns index of output blob in output array. See: inputNameToIndex()

outputNameToIndex(outputName: EmbindString): number;
outputName

output name argument (EmbindString).

Returns

The number result.

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.