Emgu.CV.OpticalFlow.Farneback C# (CSharp) Метод

Farneback() публичный статический Метод

Computes dense optical flow using Gunnar Farneback's algorithm
public static Farneback ( Byte>.Image prev0, Byte>.Image next0, Single>.Image flowX, Single>.Image flowY, double pyrScale, int levels, int winSize, int iterations, int polyN, double polySigma, CvEnum flags ) : void
prev0 Byte>.Image The first 8-bit single-channel input image
next0 Byte>.Image The second input image of the same size and the same type as prevImg
flowX Single>.Image The computed flow image for x-velocity; will have the same size as prevImg
flowY Single>.Image The computed flow image for y-velocity; will have the same size as prevImg
pyrScale double Specifies the image scale (!1) to build the pyramids for each image. pyrScale=0.5 means the classical pyramid, where each next layer is twice smaller than the previous
levels int The number of pyramid layers, including the initial image. levels=1 means that no extra layers are created and only the original images are used
winSize int The averaging window size; The larger values increase the algorithm robustness to image noise and give more chances for fast motion detection, but yield more blurred motion field
iterations int The number of iterations the algorithm does at each pyramid level
polyN int Size of the pixel neighborhood used to find polynomial expansion in each pixel. The larger values mean that the image will be approximated with smoother surfaces, yielding more robust algorithm and more blurred motion field. Typically, poly n=5 or 7
polySigma double Standard deviation of the Gaussian that is used to smooth derivatives that are used as a basis for the polynomial expansion. For poly n=5 you can set poly sigma=1.1, for poly n=7 a good value would be poly sigma=1.5
flags CvEnum The operation flags
Результат void
        public static void Farneback(
         Image<Gray, Byte> prev0,
         Image<Gray, Byte> next0,
         Image<Gray, Single> flowX,
         Image<Gray, Single> flowY,
         double pyrScale,
         int levels,
         int winSize,
         int iterations,
         int polyN,
         double polySigma,
         CvEnum.OPTICALFLOW_FARNEBACK_FLAG flags)
        {
            IntPtr flow0 = CvInvoke.cvCreateImage(prev0.Size, Emgu.CV.CvEnum.IPL_DEPTH.IPL_DEPTH_32F, 2);
             try
             {
            if ((int) (flags  & Emgu.CV.CvEnum.OPTICALFLOW_FARNEBACK_FLAG.USE_INITIAL_FLOW) != 0)
            {  //use initial flow
               CvInvoke.cvMerge(flowX.Ptr, flowY.Ptr, IntPtr.Zero, IntPtr.Zero, flow0);
            }

            CvInvoke.cvCalcOpticalFlowFarneback(prev0, next0, flow0, pyrScale, levels, winSize, iterations, polyN, polySigma, flags);
            CvInvoke.cvSplit(flow0, flowX.Ptr, flowY.Ptr, IntPtr.Zero, IntPtr.Zero);
             }
             finally
             {
            CvInvoke.cvReleaseImage(ref flow0);
             }
        }