[This is preliminary documentation and is subject to change.]
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.
Namespace:
Emgu.CVAssembly: Emgu.CV (in Emgu.CV.dll) Version: 2.0.0.0 (2.0.0.0)
Syntax
C# | Visual Basic | Visual C++ |
Public Shared Sub cvCalcOpticalFlowPyrLK ( _ prev As IntPtr, _ curr As IntPtr, _ prevPyr As IntPtr, _ currPyr As IntPtr, _ prevFeatures As PointF(), _ <OutAttribute> currFeatures As PointF(), _ count As Integer, _ winSize As Size, _ level As Integer, _ status As Byte(), _ trackError As Single(), _ criteria As MCvTermCriteria, _ flags As LKFLOW_TYPE _ )
public: static void cvCalcOpticalFlowPyrLK( IntPtr prev, IntPtr curr, IntPtr prevPyr, IntPtr currPyr, [InAttribute] array<PointF>^ prevFeatures, [OutAttribute] array<PointF>^ currFeatures, int count, Size winSize, int level, array<unsigned char>^ status, array<float>^ trackError, MCvTermCriteria criteria, LKFLOW_TYPE flags )
Parameters
- prev
- IntPtr
First frame, at time t.
- curr
- IntPtr
Second frame, at time t + dt .
- prevPyr
- IntPtr
Buffer for the pyramid for the first frame. If the pointer is not NULL , the buffer must have a sufficient size to store the pyramid from level 1 to level #level ; the total size of (image_width+8)*image_height/3 bytes is sufficient.
- currPyr
- IntPtr
Similar to prev_pyr, used for the second frame.
- prevFeatures
- array<
PointF
>[]()[]
Array of points for which the flow needs to be found.
- currFeatures
- array<
PointF
>[]()[]
Array of 2D points containing calculated new positions of input
- count
- Int32
Number of feature points.
- winSize
- Size
Size of the search window of each pyramid level.
- level
- Int32
Maximal pyramid level number. If 0 , pyramids are not used (single level), if 1 , two levels are used, etc.
- status
- array<
Byte
>[]()[]
Array. Every element of the array is set to 1 if the flow for the corresponding feature has been found, 0 otherwise.
- trackError
- array<
Single
>[]()[]
Array of double numbers containing difference between patches around the original and moved points. Optional parameter; can be NULL
- criteria
- MCvTermCriteria
Specifies when the iteration process of finding the flow for each point on each pyramid level should be stopped.
- flags
- LKFLOW_TYPE
Miscellaneous flags
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).