Table of Contents

Class DnnSuperResImpl

Namespace
OpenCvSharp.DnnSuperres
Assembly
OpenCvSharp.dll

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

  • edsr
  • espcn
  • fsrcnn
  • lapsrn
public class DnnSuperResImpl : DisposableCvObject, IDisposable, ICvPtrHolder
Inheritance
DnnSuperResImpl
Implements
Inherited Members

Constructors

DnnSuperResImpl()

Default constructor

public DnnSuperResImpl()

DnnSuperResImpl(nint)

Constructor

protected DnnSuperResImpl(nint ptr)

Parameters

ptr nint

DnnSuperResImpl(string, int)

Constructor which immediately sets the desired model

public DnnSuperResImpl(string algo, int scale)

Parameters

algo string

String containing one of the desired models: - edsr - espcn - fsrcnn - lapsrn

scale int

Integer specifying the upscale factor

Methods

DisposeUnmanaged()

releases unmanaged resources

protected override void DisposeUnmanaged()

GetAlgorithm()

Returns the scale factor of the model

public string GetAlgorithm()

Returns

string

Current algorithm.

GetScale()

Returns the scale factor of the model

public int GetScale()

Returns

int

Current scale factor.

ReadModel(string)

Read the model from the given path

public void ReadModel(string path)

Parameters

path string

Path to the model file.

ReadModel(string, string)

Read the model from the given path

public void ReadModel(string weights, string definition)

Parameters

weights string

Path to the model weights file.

definition string

Path to the model definition file.

SetModel(string, int)

Set desired model

public void SetModel(string algo, int scale)

Parameters

algo string

String containing one of the desired models: - edsr - espcn - fsrcnn - lapsrn

scale int

Integer specifying the upscale factor

SetPreferableBackend(Backend)

Ask network to use specific computation backend where it supported.

public void SetPreferableBackend(Backend backendId)

Parameters

backendId Backend

backend identifier.

SetPreferableTarget(Target)

Ask network to make computations on specific target device.

public void SetPreferableTarget(Target targetId)

Parameters

targetId Target

target identifier.

Upsample(InputArray, OutputArray)

Upsample via neural network

public void Upsample(InputArray img, OutputArray result)

Parameters

img InputArray

Image to upscale

result OutputArray

Destination upscaled image

UpsampleMultioutput(InputArray, out Mat[], IEnumerable<int>, IEnumerable<string>)

Upsample via neural network of multiple outputs

[SuppressMessage("Maintainability", "CA1508: Avoid dead conditional code")]
public void UpsampleMultioutput(InputArray img, out Mat[] imgsNew, IEnumerable<int> scaleFactors, IEnumerable<string> nodeNames)

Parameters

img InputArray

Image to upscale

imgsNew Mat[]

Destination upscaled images

scaleFactors IEnumerable<int>

Scaling factors of the output nodes

nodeNames IEnumerable<string>

Names of the output nodes in the neural network