http://www.emgu.com
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.CV
Assembly: Emgu.CV (in Emgu.CV.dll) Version: 2.4.10.1935 (2.4.10.1935)

Syntax

C#
public static void cvCalcOpticalFlowPyrLK(
	IntPtr prev,
	IntPtr curr,
	IntPtr prevPyr,
	IntPtr currPyr,
	float[,] prevFeatures,
	float[,] currFeatures,
	int count,
	Size winSize,
	int level,
	byte[] status,
	float[] trackError,
	MCvTermCriteria criteria,
	LKFLOW_TYPE flags
)
Visual Basic
Public Shared Sub cvCalcOpticalFlowPyrLK ( 
	prev As IntPtr,
	curr As IntPtr,
	prevPyr As IntPtr,
	currPyr As IntPtr,
	prevFeatures As Single(,),
	currFeatures As Single(,),
	count As Integer,
	winSize As Size,
	level As Integer,
	status As Byte(),
	trackError As Single(),
	criteria As MCvTermCriteria,
	flags As LKFLOW_TYPE
)
Visual C++
public:
static void cvCalcOpticalFlowPyrLK(
	IntPtr prev, 
	IntPtr curr, 
	IntPtr prevPyr, 
	IntPtr currPyr, 
	array<float,2>^ prevFeatures, 
	array<float,2>^ currFeatures, 
	int count, 
	Size winSize, 
	int level, 
	array<unsigned char>^ status, 
	array<float>^ trackError, 
	MCvTermCriteria criteria, 
	LKFLOW_TYPE flags
)
F#
static member cvCalcOpticalFlowPyrLK : 
        prev : IntPtr * 
        curr : IntPtr * 
        prevPyr : IntPtr * 
        currPyr : IntPtr * 
        prevFeatures : float32[,] * 
        currFeatures : float32[,] * 
        count : int * 
        winSize : Size * 
        level : int * 
        status : byte[] * 
        trackError : float32[] * 
        criteria : MCvTermCriteria * 
        flags : LKFLOW_TYPE -> unit 

Parameters

prev
Type: System..::..IntPtr
First frame, at time t.
curr
Type: System..::..IntPtr
Second frame, at time t + dt .
prevPyr
Type: System..::..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
Type: System..::..IntPtr
Similar to prev_pyr, used for the second frame.
prevFeatures
Type: array<System..::..Single,2>[,](,)[,][,]
Array of points for which the flow needs to be found.
currFeatures
Type: array<System..::..Single,2>[,](,)[,][,]
Array of 2D points containing calculated new positions of input
count
Type: System..::..Int32
Number of feature points.
winSize
Type: System.Drawing..::..Size
Size of the search window of each pyramid level.
level
Type: System..::..Int32
Maximal pyramid level number. If 0 , pyramids are not used (single level), if 1 , two levels are used, etc.
status
Type: array<System..::..Byte>[]()[][]
Array. Every element of the array is set to 1 if the flow for the corresponding feature has been found, 0 otherwise.
trackError
Type: array<System..::..Single>[]()[][]
Array of double numbers containing difference between patches around the original and moved points. Optional parameter; can be NULL
criteria
Type: Emgu.CV.Structure..::..MCvTermCriteria
Specifies when the iteration process of finding the flow for each point on each pyramid level should be stopped.
flags
Type: Emgu.CV.CvEnum..::..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).

See Also