Calculates the optical flow for a sparse feature set using the iterative LucasKanade method with pyramids
Parameters: 


The function implements the sparse iterative version of the LucasKanade optical flow in pyramids, see Bouguet00 .
Computes dense optical flow using Gunnar Farneback’s algorithm
Parameters: 


The function finds optical flow for each prevImg pixel using the alorithm so that
Updates the motion history image by a moving silhouette.
Parameters: 


The function updates the motion history image as following:
That is, MHI pixels where motion occurs are set to the current timestamp , while the pixels where motion happened last time a long time ago are cleared.
The function, together with calcMotionGradient() and calcGlobalOrientation() , implements the motion templates technique, described in Davis97 and Bradski00 . See also the OpenCV sample motempl.c that demonstrates the use of all the motion template functions.
Calculates the gradient orientation of a motion history image.
Parameters: 


The function calculates the gradient orientation at each pixel as:
(in fact, fastArctan() and phase() are used, so that the computed angle is measured in degrees and covers the full range 0..360). Also, the mask is filled to indicate pixels where the computed angle is valid.
Calculates the global motion orientation in some selected region.
Parameters: 


The function calculates the average motion direction in the selected region and returns the angle between 0 degrees and 360 degrees. The average direction is computed from the weighted orientation histogram, where a recent motion has larger weight and the motion occurred in the past has smaller weight, as recorded in mhi .
Finds the object center, size, and orientation
Parameters: 


The function implements the CAMSHIFT object tracking algrorithm Bradski98 . First, it finds an object center using meanShift() and then adjust the window size and finds the optimal rotation. The function returns the rotated rectangle structure that includes the object position, size and the orientation. The next position of the search window can be obtained with RotatedRect::boundingRect() .
See the OpenCV sample camshiftdemo.c that tracks colored objects.
Finds the object on a back projection image.
Parameters: 


The function implements iterative object search algorithm. It takes the object back projection on input and the initial position. The mass center in window of the back projection image is computed and the search window center shifts to the mass center. The procedure is repeated until the specified number of iterations criteria.maxCount is done or until the window center shifts by less than criteria.epsilon . The algorithm is used inside CamShift() and, unlike CamShift() , the search window size or orientation do not change during the search. You can simply pass the output of calcBackProject() to this function, but better results can be obtained if you prefilter the back projection and remove the noise (e.g. by retrieving connected components with findContours() , throwing away contours with small area ( contourArea() ) and rendering the remaining contours with drawContours() )
Kalman filter class
class KalmanFilter
{
public:
KalmanFilter();
KalmanFilter(int dynamParams, int measureParams, int controlParams=0);
void init(int dynamParams, int measureParams, int controlParams=0);
// predicts statePre from statePost
const Mat& predict(const Mat& control=Mat());
// corrects statePre based on the input measurement vector
// and stores the result to statePost.
const Mat& correct(const Mat& measurement);
Mat statePre; // predicted state (x'(k)):
// x(k)=A*x(k1)+B*u(k)
Mat statePost; // corrected state (x(k)):
// x(k)=x'(k)+K(k)*(z(k)H*x'(k))
Mat transitionMatrix; // state transition matrix (A)
Mat controlMatrix; // control matrix (B)
// (it is not used if there is no control)
Mat measurementMatrix; // measurement matrix (H)
Mat processNoiseCov; // process noise covariance matrix (Q)
Mat measurementNoiseCov;// measurement noise covariance matrix (R)
Mat errorCovPre; // priori error estimate covariance matrix (P'(k)):
// P'(k)=A*P(k1)*At + Q)*/
Mat gain; // Kalman gain matrix (K(k)):
// K(k)=P'(k)*Ht*inv(H*P'(k)*Ht+R)
Mat errorCovPost; // posteriori error estimate covariance matrix (P(k)):
// P(k)=(IK(k)*H)*P'(k)
...
};
The class implements standard Kalman filter http://en.wikipedia.org/wiki/Kalman_filter . However, you can modify transitionMatrix , controlMatrix and measurementMatrix to get the extended Kalman filter functionality. See the OpenCV sample kalman.c