Skip to content

DISOpticalFlow

Motion and trackingclassOpenCV 5.0.0
import { DISOpticalFlow } 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. Inherits DenseOpticalFlow.

DIS optical flow algorithm.

This class implements the Dense Inverse Search (DIS) optical flow algorithm. More details about the algorithm can be found at [Kroeger2016] . Includes three presets with preselected parameters to provide reasonable trade-off between speed and quality. However, even the slowest preset is still relatively fast, use DeepFlow if you need better quality and don't care about speed.

This implementation includes several additional features compared to the algorithm described in the paper, including spatial propagation of flow vectors (getUseSpatialPropagation), as well as an option to utilize an initial flow approximation passed to calc (which is, essentially, temporal propagation, if the previous frame's flow field is passed).

Constructors and members

static create

Creates an instance of DISOpticalFlow

create(preset: number): DISOpticalFlow | null;
2 available overloads
create(): DISOpticalFlow | null;
create(preset: number): DISOpticalFlow | null;
preset

one of PRESET_ULTRAFAST, PRESET_FAST and PRESET_MEDIUM

Returns

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

getFinestScale

Finest level of the Gaussian pyramid on which the flow is computed (zero level corresponds to the original image resolution). The final flow is obtained by bilinear upscaling. See: setFinestScale

getFinestScale(): number;
Returns

The number result.

setFinestScale

Finest level of the Gaussian pyramid on which the flow is computed (zero level corresponds to the original image resolution). The final flow is obtained by bilinear upscaling. See: setFinestScale See: getFinestScale

setFinestScale(val: number): void;
val

val argument (number).

setCoarsestScale

Sets the coarsest scale

setCoarsestScale(val: number): void;
val

Coarsest level of the Gaussian pyramid on which the flow is computed. If set to -1, the auto-computed coarsest scale will be used.

getCoarsestScale

Gets the coarsest scale

getCoarsestScale(): number;
Returns

The number result.

getPatchSize

Size of an image patch for matching (in pixels). Normally, default 8x8 patches work well enough in most cases. See: setPatchSize

getPatchSize(): number;
Returns

The number result.

setPatchSize

Size of an image patch for matching (in pixels). Normally, default 8x8 patches work well enough in most cases. See: setPatchSize See: getPatchSize

setPatchSize(val: number): void;
val

val argument (number).

getPatchStride

Stride between neighbor patches. Must be less than patch size. Lower values correspond to higher flow quality. See: setPatchStride

getPatchStride(): number;
Returns

The number result.

setPatchStride

Stride between neighbor patches. Must be less than patch size. Lower values correspond to higher flow quality. See: setPatchStride See: getPatchStride

setPatchStride(val: number): void;
val

val argument (number).

getGradientDescentIterations

Maximum number of gradient descent iterations in the patch inverse search stage. Higher values may improve quality in some cases. See: setGradientDescentIterations

getGradientDescentIterations(): number;
Returns

The number result.

setGradientDescentIterations

Maximum number of gradient descent iterations in the patch inverse search stage. Higher values may improve quality in some cases. See: setGradientDescentIterations See: getGradientDescentIterations

setGradientDescentIterations(val: number): void;
val

val argument (number).

getVariationalRefinementIterations

Number of fixed point iterations of variational refinement per scale. Set to zero to disable variational refinement completely. Higher values will typically result in more smooth and high-quality flow. See: setGradientDescentIterations

getVariationalRefinementIterations(): number;
Returns

The number result.

setVariationalRefinementIterations

Maximum number of gradient descent iterations in the patch inverse search stage. Higher values may improve quality in some cases. See: setGradientDescentIterations See: getGradientDescentIterations

setVariationalRefinementIterations(val: number): void;
val

val argument (number).

getVariationalRefinementAlpha

Weight of the smoothness term See: setVariationalRefinementAlpha

getVariationalRefinementAlpha(): number;
Returns

The number result.

setVariationalRefinementAlpha

Weight of the smoothness term See: setVariationalRefinementAlpha See: getVariationalRefinementAlpha

setVariationalRefinementAlpha(val: number): void;
val

val argument (number).

getVariationalRefinementDelta

Weight of the color constancy term See: setVariationalRefinementDelta

getVariationalRefinementDelta(): number;
Returns

The number result.

setVariationalRefinementDelta

Weight of the color constancy term See: setVariationalRefinementDelta See: getVariationalRefinementDelta

setVariationalRefinementDelta(val: number): void;
val

val argument (number).

getVariationalRefinementGamma

Weight of the gradient constancy term See: setVariationalRefinementGamma

getVariationalRefinementGamma(): number;
Returns

The number result.

setVariationalRefinementGamma

Weight of the gradient constancy term See: setVariationalRefinementGamma See: getVariationalRefinementGamma

setVariationalRefinementGamma(val: number): void;
val

val argument (number).

getVariationalRefinementEpsilon

Norm value shift for robust penalizer See: setVariationalRefinementEpsilon

getVariationalRefinementEpsilon(): number;
Returns

The number result.

setVariationalRefinementEpsilon

Norm value shift for robust penalizer See: setVariationalRefinementEpsilon See: getVariationalRefinementEpsilon

setVariationalRefinementEpsilon(val: number): void;
val

val argument (number).

getUseMeanNormalization

Whether to use mean-normalization of patches when computing patch distance. It is turned on by default as it typically provides a noticeable quality boost because of increased robustness to illumination variations. Turn it off if you are certain that your sequence doesn't contain any changes in illumination. See: setUseMeanNormalization

getUseMeanNormalization(): boolean;
Returns

The boolean result.

setUseMeanNormalization

Whether to use mean-normalization of patches when computing patch distance. It is turned on by default as it typically provides a noticeable quality boost because of increased robustness to illumination variations. Turn it off if you are certain that your sequence doesn't contain any changes in illumination. See: setUseMeanNormalization See: getUseMeanNormalization

setUseMeanNormalization(val: boolean): void;
val

val argument (boolean).

getUseSpatialPropagation

Whether to use spatial propagation of good optical flow vectors. This option is turned on by default, as it tends to work better on average and can sometimes help recover from major errors introduced by the coarse-to-fine scheme employed by the DIS optical flow algorithm. Turning this option off can make the output flow field a bit smoother, however. See: setUseSpatialPropagation

getUseSpatialPropagation(): boolean;
Returns

The boolean result.

setUseSpatialPropagation

Whether to use spatial propagation of good optical flow vectors. This option is turned on by default, as it tends to work better on average and can sometimes help recover from major errors introduced by the coarse-to-fine scheme employed by the DIS optical flow algorithm. Turning this option off can make the output flow field a bit smoother, however. See: setUseSpatialPropagation See: getUseSpatialPropagation

setUseSpatialPropagation(val: boolean): void;
val

val argument (boolean).

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.