Beispiel #1
0
 internal static extern IntPtr cveSparsePyrLKOpticalFlowCreate(
     ref Size winSize,
     int maxLevel,
     ref MCvTermCriteria crit,
     CvEnum.LKFlowFlag flags,
     double minEigThreshold,
     ref IntPtr sparseOpticalFlow,
     ref IntPtr algorithm);
Beispiel #2
0
 private static extern void cveCalcOpticalFlowPyrLK(
     IntPtr prevImg,
     IntPtr nextImg,
     IntPtr prevPts,
     IntPtr nextPts,
     IntPtr status,
     IntPtr err,
     ref Size winSize,
     int maxLevel,
     ref MCvTermCriteria criteria,
     CvEnum.LKFlowFlag flags,
     double minEigenThreshold);
Beispiel #3
0
 public SparsePyrLKOpticalFlow(
     Size winSize,
     int maxLevel,
     MCvTermCriteria crit,
     CvEnum.LKFlowFlag flags,
     double minEigThreshold)
 {
     _ptr = CvInvoke.cveSparsePyrLKOpticalFlowCreate(
         ref winSize,
         maxLevel,
         ref crit,
         flags,
         minEigThreshold,
         ref _sparseOpticalFlow,
         ref _algorithm);
 }
Beispiel #4
0
 /// <summary>
 /// Implements sparse iterative version of Lucas-Kanade optical flow in pyramids ([Bouguet00]). It calculates coordinates of the feature points on the current video frame given their coordinates on the previous frame. The function finds the coordinates with sub-pixel accuracy.
 /// </summary>
 /// <remarks>Both parameters prev_pyr and curr_pyr comply with the following rules: if the image pointer is 0, the function allocates the buffer internally, calculates the pyramid, and releases the buffer after processing. Otherwise, the function calculates the pyramid and stores it in the buffer unless the flag CV_LKFLOW_PYR_A[B]_READY is set. The image should be large enough to fit the Gaussian pyramid data. After the function call both pyramids are calculated and the readiness flag for the corresponding image can be set in the next call (i.e., typically, for all the image pairs except the very first one CV_LKFLOW_PYR_A_READY is set). </remarks>
 /// <param name="prevImg">First frame, at time t. </param>
 /// <param name="nextImg">Second frame, at time t + dt .</param>
 /// <param name="prevPts">Array of points for which the flow needs to be found. </param>
 /// <param name="nextPts">Array of 2D points containing calculated new positions of input </param>
 /// <param name="winSize">Size of the search window of each pyramid level.</param>
 /// <param name="maxLevel">Maximal pyramid level number. If 0 , pyramids are not used (single level), if 1 , two levels are used, etc. </param>
 /// <param name="status">Array. Every element of the array is set to 1 if the flow for the corresponding feature has been found, 0 otherwise.</param>
 /// <param name="err">Array of double numbers containing difference between patches around the original and moved points. Optional parameter; can be NULL </param>
 /// <param name="criteria">Specifies when the iteration process of finding the flow for each point on each pyramid level should be stopped.</param>
 /// <param name="flags">Miscellaneous flags</param>
 /// <param name="minEigThreshold">the algorithm calculates the minimum eigen value of a 2x2 normal matrix of optical flow equations (this matrix is called a spatial gradient matrix in [Bouguet00]), divided by number of pixels in a window; if this value is less than minEigThreshold, then a corresponding feature is filtered out and its flow is not processed, so it allows to remove bad points and get a performance boost.</param>
 public static void CalcOpticalFlowPyrLK(
     IInputArray prevImg,
     IInputArray nextImg,
     IInputArray prevPts,
     IInputOutputArray nextPts,
     IOutputArray status,
     IOutputArray err,
     Size winSize,
     int maxLevel,
     MCvTermCriteria criteria,
     CvEnum.LKFlowFlag flags = CvEnum.LKFlowFlag.Default,
     double minEigThreshold  = 1.0e-4)
 {
     using (InputArray iaPrevImg = prevImg.GetInputArray())
         using (InputArray iaNextImg = nextImg.GetInputArray())
             using (InputArray iaPrevPts = prevPts.GetInputArray())
                 using (InputOutputArray ioaNextPts = nextPts.GetInputOutputArray())
                     using (OutputArray oaStatus = status.GetOutputArray())
                         using (OutputArray oaErr = err.GetOutputArray())
                             cveCalcOpticalFlowPyrLK(iaPrevImg, iaNextImg, iaPrevPts, ioaNextPts, oaStatus, oaErr, ref winSize, maxLevel, ref criteria, flags, minEigThreshold);
 }