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
orientationInputArrayMotion gradient orientation image calculated by the function CalcMotionGradient() .
maskInputArrayMask 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.
mhiInputArrayMotion history image calculated by UpdateMotionHistory() .
timestampdoubleTimestamp passed to UpdateMotionHistory() .
durationdoubleMaximum duration of a motion track in milliseconds, passed to UpdateMotionHistory() .
Returns
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
mhiInputArrayMotion history single-channel floating-point image.
maskOutputArrayOutput 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.
orientationOutputArrayOutput 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.
delta1doubleMinimal (or maximal) allowed difference between mhi values within a pixel neighborhood.
delta2doubleMaximal (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).
apertureSizeint
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
fromInputArrayFirst 8-bit 3-channel image.
toInputArraySecond 8-bit 3-channel image
flowOutputArrayEstimated flow
layersintNumber of layers
averagingBlockSizeintSize of block through which we sum up when calculate cost function for pixel
maxFlowintmaximal 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
fromInputArrayFirst 8-bit 3-channel image.
toInputArraySecond 8-bit 3-channel image
flowOutputArrayEstimated flow
layersintNumber of layers
averagingBlockSizeintSize of block through which we sum up when calculate cost function for pixel
maxFlowintmaximal flow that we search at each level
sigmaDistdoublevector smooth spatial sigma parameter
sigmaColordoublevector smooth color sigma parameter
postprocessWindowintwindow size for postprocess cross bilateral filter
sigmaDistFixdoublespatial sigma for postprocess cross bilateralf filter
sigmaColorFixdoublecolor sigma for postprocess cross bilateral filter
occThrdoublethreshold for detecting occlusions
upscaleAveragingRadiusintwindow size for bilateral upscale operation
upscaleSigmaDistdoublespatial sigma for bilateral upscale operation
upscaleSigmaColordoublecolor sigma for bilateral upscale operation
speedUpThrdoublethreshold 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
fromInputArrayfirst 8-bit 3-channel or 1-channel image.
toInputArraysecond 8-bit 3-channel or 1-channel image of the same size as from
flowOutputArraycomputed flow image that has the same size as from and CV_32FC2 type
gridStepintstride used in sparse match computation. Lower values usually result in higher quality but slow down the algorithm.
kintnumber 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.
sigmafloatparameter 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.
usePostProcbooldefines whether the ximgproc::fastGlobalSmootherFilter() is used for post-processing after interpolation
fgsLambdafloatsee the respective parameter of the ximgproc::fastGlobalSmootherFilter()
fgsSigmafloatsee 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
mhiInputArrayMotion history image.
segmaskOutputArrayImage where the found mask should be stored, single-channel, 32-bit floating-point.
boundingRectsRect[]Vector containing ROIs of motion connected components.
timestampdoubleCurrent time in milliseconds or other units.
segThreshdoubleSegmentation 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
silhouetteInputArraySilhouette mask that has non-zero pixels where the motion occurs.
mhiInputOutputArrayMotion history image that is updated by the function (single-channel, 32-bit floating-point).
timestampdoubleCurrent time in milliseconds or other units.
durationdoubleMaximal duration of the motion track in the same units as timestamp .