Table of Contents

Class Cv2.OptFlow

Namespace
OpenCvSharp
Assembly
OpenCvSharp.dll

cv::optflow functions

public static class Cv2.OptFlow
Inheritance
Cv2.OptFlow
Inherited Members

Methods

CalcGlobalOrientation(InputArray, InputArray, InputArray, double, double)

Computes the global orientation of the selected motion history image part

public static double CalcGlobalOrientation(InputArray orientation, InputArray mask, InputArray mhi, double timestamp, double duration)

Parameters

orientation InputArray

Motion gradient orientation image calculated by the function CalcMotionGradient() .

mask InputArray

Mask image. It may be a conjunction of a valid gradient mask, also calculated by CalcMotionGradient() , and the mask of a region whose direction needs to be calculated.

mhi InputArray

Motion history image calculated by UpdateMotionHistory() .

timestamp double

Timestamp passed to UpdateMotionHistory() .

duration double

Maximum duration of a motion track in milliseconds, passed to UpdateMotionHistory() .

Returns

double

CalcMotionGradient(InputArray, OutputArray, OutputArray, double, double, int)

Computes the motion gradient orientation image from the motion history image

public static void CalcMotionGradient(InputArray mhi, OutputArray mask, OutputArray orientation, double delta1, double delta2, int apertureSize = 3)

Parameters

mhi InputArray

Motion history single-channel floating-point image.

mask OutputArray

Output mask image that has the type CV_8UC1 and the same size as mhi. Its non-zero elements mark pixels where the motion gradient data is correct.

orientation OutputArray

Output motion gradient orientation image that has the same type and the same size as mhi. Each pixel of the image is a motion orientation, from 0 to 360 degrees.

delta1 double

Minimal (or maximal) allowed difference between mhi values within a pixel neighborhood.

delta2 double

Maximal (or minimal) allowed difference between mhi values within a pixel neighborhood. That is, the function finds the minimum ( m(x,y) ) and maximum ( M(x,y) ) mhi values over 3x3 neighborhood of each pixel and marks the motion orientation at (x, y) as valid only if: min(delta1, delta2) <= M(x,y)-m(x,y) <= max(delta1, delta2).

apertureSize int

CalcOpticalFlowSF(InputArray, InputArray, OutputArray, int, int, int)

computes dense optical flow using Simple Flow algorithm

public static void CalcOpticalFlowSF(InputArray from, InputArray to, OutputArray flow, int layers, int averagingBlockSize, int maxFlow)

Parameters

from InputArray

First 8-bit 3-channel image.

to InputArray

Second 8-bit 3-channel image

flow OutputArray

Estimated flow

layers int

Number of layers

averagingBlockSize int

Size of block through which we sum up when calculate cost function for pixel

maxFlow int

maximal flow that we search at each level

CalcOpticalFlowSF(InputArray, InputArray, OutputArray, int, int, int, double, double, int, double, double, double, int, double, double, double)

computes dense optical flow using Simple Flow algorithm

public static void CalcOpticalFlowSF(InputArray from, InputArray to, OutputArray flow, int layers, int averagingBlockSize, int maxFlow, double sigmaDist, double sigmaColor, int postprocessWindow, double sigmaDistFix, double sigmaColorFix, double occThr, int upscaleAveragingRadius, double upscaleSigmaDist, double upscaleSigmaColor, double speedUpThr)

Parameters

from InputArray

First 8-bit 3-channel image.

to InputArray

Second 8-bit 3-channel image

flow OutputArray

Estimated flow

layers int

Number of layers

averagingBlockSize int

Size of block through which we sum up when calculate cost function for pixel

maxFlow int

maximal flow that we search at each level

sigmaDist double

vector smooth spatial sigma parameter

sigmaColor double

vector smooth color sigma parameter

postprocessWindow int

window size for postprocess cross bilateral filter

sigmaDistFix double

spatial sigma for postprocess cross bilateralf filter

sigmaColorFix double

color sigma for postprocess cross bilateral filter

occThr double

threshold for detecting occlusions

upscaleAveragingRadius int

window size for bilateral upscale operation

upscaleSigmaDist double

spatial sigma for bilateral upscale operation

upscaleSigmaColor double

color sigma for bilateral upscale operation

speedUpThr double

threshold to detect point with irregular flow - where flow should be recalculated after upscale

CalcOpticalFlowSparseToDense(InputArray, InputArray, OutputArray, int, int, float, bool, float, float)

Fast dense optical flow based on PyrLK sparse matches interpolation.

public static void CalcOpticalFlowSparseToDense(InputArray from, InputArray to, OutputArray flow, int gridStep = 8, int k = 128, float sigma = 0.05, bool usePostProc = true, float fgsLambda = 500, float fgsSigma = 1.5)

Parameters

from InputArray

first 8-bit 3-channel or 1-channel image.

to InputArray

second 8-bit 3-channel or 1-channel image of the same size as from

flow OutputArray

computed flow image that has the same size as from and CV_32FC2 type

gridStep int

stride used in sparse match computation. Lower values usually result in higher quality but slow down the algorithm.

k int

number of nearest-neighbor matches considered, when fitting a locally affine model. Lower values can make the algorithm noticeably faster at the cost of some quality degradation.

sigma float

parameter defining how fast the weights decrease in the locally-weighted affine fitting. Higher values can help preserve fine details, lower values can help to get rid of the noise in the output flow.

usePostProc bool

defines whether the ximgproc::fastGlobalSmootherFilter() is used for post-processing after interpolation

fgsLambda float

see the respective parameter of the ximgproc::fastGlobalSmootherFilter()

fgsSigma float

see the respective parameter of the ximgproc::fastGlobalSmootherFilter()

SegmentMotion(InputArray, OutputArray, out Rect[], double, double)

Splits a motion history image into a few parts corresponding to separate independent motions (for example, left hand, right hand).

public static void SegmentMotion(InputArray mhi, OutputArray segmask, out Rect[] boundingRects, double timestamp, double segThresh)

Parameters

mhi InputArray

Motion history image.

segmask OutputArray

Image where the found mask should be stored, single-channel, 32-bit floating-point.

boundingRects Rect[]

Vector containing ROIs of motion connected components.

timestamp double

Current time in milliseconds or other units.

segThresh double

Segmentation threshold that is recommended to be equal to the interval between motion history “steps” or greater.

UpdateMotionHistory(InputArray, InputOutputArray, double, double)

Updates motion history image using the current silhouette

public static void UpdateMotionHistory(InputArray silhouette, InputOutputArray mhi, double timestamp, double duration)

Parameters

silhouette InputArray

Silhouette mask that has non-zero pixels where the motion occurs.

mhi InputOutputArray

Motion history image that is updated by the function (single-channel, 32-bit floating-point).

timestamp double

Current time in milliseconds or other units.

duration double

Maximal duration of the motion track in the same units as timestamp .