OpenCvSharp.Cv2.SegmentMotion C# (CSharp) Method

SegmentMotion() public static method

Splits a motion history image into a few parts corresponding to separate independent motions (for example, left hand, right hand).
public static SegmentMotion ( InputArray mhi, OutputArray segmask, Rect &boundingRects, double timestamp, double segThresh ) : void
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.
return void
        public static void SegmentMotion(
            InputArray mhi, OutputArray segmask,
            out Rect[] boundingRects,
            double timestamp, double segThresh)
        {
            if (mhi == null)
                throw new ArgumentNullException(nameof(mhi));
            if (segmask == null)
                throw new ArgumentNullException(nameof(segmask));
            mhi.ThrowIfDisposed();
            segmask.ThrowIfNotReady();

            using (var br = new VectorOfRect())
            {
                NativeMethods.optflow_motempl_segmentMotion(
                    mhi.CvPtr, segmask.CvPtr, br.CvPtr, timestamp, segThresh);
                boundingRects = br.ToArray();
            }
            segmask.Fix();
        }
Cv2