Skip to content

dnn_superres_DnnSuperResImpl

dnn_superresclassOpenCV 5.0.0
import { dnn_superres_DnnSuperResImpl } from '@banou/opencv-wasm'

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

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

A class to upscale images via convolutional neural networks. The following four models are implemented:

  • edsr
  • espcn
  • fsrcnn
  • lapsrn

Constructors and members

static create

Empty constructor for python

create(): dnn_superres_DnnSuperResImpl | null;
Returns

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

readModel

Read the model from the given path

readModel(path: EmbindString): void;
path

Path to the model file.

setModel

Set desired model

setModel(algo: EmbindString, scale: number): void;
algo

String containing one of the desired models:

  • edsr
  • espcn
  • fsrcnn
  • lapsrn
scale

Integer specifying the upscale factor

setPreferableBackend

Set computation backend

setPreferableBackend(backendId: number): void;
backendId

backend id argument (number).

setPreferableTarget

Set computation target

setPreferableTarget(targetId: number): void;
targetId

target id argument (number).

upsample

Upsample via neural network

upsample(img: Mat, result: Mat): void;
img

Image to upscale

result

Output destination, filled by the native operation. Destination upscaled image

upsampleMultioutput

Upsample via neural network of multiple outputs

upsampleMultioutput(img: Mat, imgs_new: MatVector, scale_factors: IntVector, node_names: StringVector): void;
img

Image to upscale

imgs_new

Destination upscaled images

scale_factors

Scaling factors of the output nodes

node_names

Names of the output nodes in the neural network

getScale

Returns the scale factor of the model:

getScale(): number;
Returns

Current scale factor.

getAlgorithm

Returns the scale factor of the model:

getAlgorithm(): string;
Returns

Current algorithm.

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.