Calculates an optical flow for a sparse feature set using the iterative Lucas-Kanade method with pyramids.
Parameters: |
|
---|
The function implements a sparse iterative version of the Lucas-Kanade optical flow in pyramids. See [Bouguet00]. The function is parallelized with the TBB library.
Note
Constructs the image pyramid which can be passed to calcOpticalFlowPyrLK().
Parameters: |
|
---|---|
Returns: | number of levels in constructed pyramid. Can be less than maxLevel. |
Computes a dense optical flow using the Gunnar Farneback’s algorithm.
Parameters: |
|
---|
The function finds an optical flow for each prev pixel using the [Farneback2003] algorithm so that
Note
Computes an optimal affine transformation between two 2D point sets.
Parameters: |
|
---|
The function finds an optimal affine transform [A|b] (a 2 x 3 floating-point matrix) that approximates best the affine transformation between:
- Two point sets
- Two raster images. In this case, the function first finds some features in the src image and finds the corresponding features in dst image. After that, the problem is reduced to the first case.
In case of point sets, the problem is formulated as follows: you need to find a 2x2 matrix A and 2x1 vector b so that:
where src[i] and dst[i] are the i-th points in src and dst, respectively
can be either arbitrary (when fullAffine=true ) or have a form of
when fullAffine=false .
Finds the geometric transform (warp) between two images in terms of the ECC criterion [EP08].
Parameters: |
|
---|
The function estimates the optimum transformation (warpMatrix) with respect to ECC criterion ([EP08]), that is
where
(the equation holds with homogeneous coordinates for homography). It returns the final enhanced correlation coefficient, that is the correlation coefficient between the template image and the final warped input image. When a matrix is given with motionType =0, 1 or 2, the third row is ignored.
Unlike findHomography() and estimateRigidTransform(), the function findTransformECC() implements an area-based alignment that builds on intensity similarities. In essence, the function updates the initial transformation that roughly aligns the images. If this information is missing, the identity warp (unity matrix) should be given as input. Note that if images undergo strong displacements/rotations, an initial transformation that roughly aligns the images is necessary (e.g., a simple euclidean/similarity transform that allows for the images showing the same image content approximately). Use inverse warping in the second image to take an image close to the first one, i.e. use the flag WARP_INVERSE_MAP with warpAffine() or warpPerspective(). See also the OpenCV sample image_alignment.cpp that demonstrates the use of the function. Note that the function throws an exception if algorithm does not converges.
See also
Finds an object center, size, and orientation.
Parameters: |
|
---|---|
Returns: | (in old interfaces) Number of iterations CAMSHIFT took to converge |
The function implements the CAMSHIFT object tracking algorithm [Bradski98]. First, it finds an object center using meanShift() and then adjusts the window size and finds the optimal rotation. The function returns the rotated rectangle structure that includes the object position, size, and orientation. The next position of the search window can be obtained with RotatedRect::boundingRect() .
See the OpenCV sample camshiftdemo.c that tracks colored objects.
Note
Finds an object on a back projection image.
Parameters: |
|
---|---|
Returns: | Number of iterations CAMSHIFT took to converge. |
The function implements the iterative object search algorithm. It takes the input back projection of an object 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 pre-filter the back projection and remove the noise. For example, you can do this by retrieving connected components with findContours() , throwing away contours with small area ( contourArea() ), and rendering the remaining contours with drawContours() .
Note
Kalman filter class.
The class implements a standard Kalman filter http://en.wikipedia.org/wiki/Kalman_filter, [Welch95]. However, you can modify transitionMatrix, controlMatrix, and measurementMatrix to get an extended Kalman filter functionality. See the OpenCV sample kalman.cpp .
Note
The constructors.
The full constructor.
Parameters: |
|
---|
Note
In C API when CvKalman* kalmanFilter structure is not needed anymore, it should be released with cvReleaseKalman(&kalmanFilter)
Re-initializes Kalman filter. The previous content is destroyed.
Parameters: |
|
---|
Computes a predicted state.
Parameters: |
|
---|
Updates the predicted state from the measurement.
Parameters: |
|
---|
Base class for background/foreground segmentation.
class BackgroundSubtractor : public Algorithm
{
public:
virtual ~BackgroundSubtractor();
virtual void apply(InputArray image, OutputArray fgmask, double learningRate=0);
virtual void getBackgroundImage(OutputArray backgroundImage) const;
};
The class is only used to define the common interface for the whole family of background/foreground segmentation algorithms.
Computes a foreground mask.
Parameters: |
|
---|
Computes a background image.
Parameters: |
|
---|
Note
Sometimes the background image can be very blurry, as it contain the average background statistics.
Gaussian Mixture-based Background/Foreground Segmentation Algorithm.
The class implements the algorithm described in [KB2001].
Creates mixture-of-gaussian background subtractor
Parameters: |
|
---|
Gaussian Mixture-based Background/Foreground Segmentation Algorithm.
The class implements the Gaussian mixture model background subtraction described in [Zivkovic2004] and [Zivkovic2006] .
Creates MOG2 Background Subtractor
Parameters: |
|
---|
Returns the number of last frames that affect the background model
Sets the number of last frames that affect the background model
Returns the number of gaussian components in the background model
Sets the number of gaussian components in the background model. The model needs to be reinitalized to reserve memory.
Returns the “background ratio” parameter of the algorithm
If a foreground pixel keeps semi-constant value for about backgroundRatio*history frames, it’s considered background and added to the model as a center of a new component. It corresponds to TB parameter in the paper.
Sets the “background ratio” parameter of the algorithm
Returns the variance threshold for the pixel-model match
The main threshold on the squared Mahalanobis distance to decide if the sample is well described by the background model or not. Related to Cthr from the paper.
Sets the variance threshold for the pixel-model match
Returns the variance threshold for the pixel-model match used for new mixture component generation
Threshold for the squared Mahalanobis distance that helps decide when a sample is close to the existing components (corresponds to Tg in the paper). If a pixel is not close to any component, it is considered foreground or added as a new component. 3 sigma => Tg=3*3=9 is default. A smaller Tg value generates more components. A higher Tg value may result in a small number of components but they can grow too large.
Sets the variance threshold for the pixel-model match used for new mixture component generation
Returns the initial variance of each gaussian component
Sets the initial variance of each gaussian component
Returns the complexity reduction threshold
This parameter defines the number of samples needed to accept to prove the component exists. CT=0.05 is a default value for all the samples. By setting CT=0 you get an algorithm very similar to the standard Stauffer&Grimson algorithm.
Sets the complexity reduction threshold
Returns the shadow detection flag
If true, the algorithm detects shadows and marks them. See createBackgroundSubtractorMOG2 for details.
Enables or disables shadow detection
Returns the shadow value
Shadow value is the value used to mark shadows in the foreground mask. Default value is 127. Value 0 in the mask always means background, 255 means foreground.
Sets the shadow value
Returns the shadow threshold
A shadow is detected if pixel is a darker version of the background. The shadow threshold (Tau in the paper) is a threshold defining how much darker the shadow can be. Tau= 0.5 means that if a pixel is more than twice darker then it is not shadow. See Prati, Mikic, Trivedi and Cucchiarra, Detecting Moving Shadows..., IEEE PAMI,2003.
Sets the shadow threshold
K-nearest neigbours - based Background/Foreground Segmentation Algorithm.
The class implements the K-nearest neigbours background subtraction described in [Zivkovic2006] . Very efficient if number of foreground pixels is low.
Creates KNN Background Subtractor
Parameters: |
|
---|
Returns the number of last frames that affect the background model
Sets the number of last frames that affect the background model
Returns the number of data samples in the background model
Sets the number of data samples in the background model. The model needs to be reinitalized to reserve memory.
Returns the threshold on the squared distance between the pixel and the sample
The threshold on the squared distance between the pixel and the sample to decide whether a pixel is close to a data sample.
Sets the threshold on the squared distance
Returns the number of neighbours, the k in the kNN. K is the number of samples that need to be within dist2Threshold in order to decide that that pixel is matching the kNN background model.
Sets the k in the kNN. How many nearest neigbours need to match.
Returns the shadow detection flag
If true, the algorithm detects shadows and marks them. See createBackgroundSubtractorKNN for details.
Enables or disables shadow detection
Returns the shadow value
Shadow value is the value used to mark shadows in the foreground mask. Default value is 127. Value 0 in the mask always means background, 255 means foreground.
Sets the shadow value
Returns the shadow threshold
A shadow is detected if pixel is a darker version of the background. The shadow threshold (Tau in the paper) is a threshold defining how much darker the shadow can be. Tau= 0.5 means that if a pixel is more than twice darker then it is not shadow. See Prati, Mikic, Trivedi and Cucchiarra, Detecting Moving Shadows..., IEEE PAMI,2003.
Sets the shadow threshold
Background Subtractor module based on the algorithm given in [Gold2012].
Creates a GMG Background Subtractor
Parameters: |
|
---|
Returns the number of frames used to initialize background model.
Sets the number of frames used to initialize background model.
Returns the learning rate of the algorithm. It lies between 0.0 and 1.0. It determines how quickly features are “forgotten” from histograms.
Sets the learning rate of the algorithm.
Returns the value of decision threshold. Decision value is the value above which pixel is determined to be FG.
Sets the value of decision threshold.
Returns total number of distinct colors to maintain in histogram.
Sets total number of distinct colors to maintain in histogram.
Returns the parameter used for quantization of color-space. It is the number of discrete levels in each channel to be used in histograms.
Sets the parameter used for quantization of color-space
Returns the kernel radius used for morphological operations
Sets the kernel radius used for morphological operations
Returns the status of background model update
Sets the status of background model update
Returns the minimum value taken on by pixels in image sequence. Usually 0.
Sets the minimum value taken on by pixels in image sequence.
Returns the maximum value taken on by pixels in image sequence. e.g. 1.0 or 255.
Sets the maximum value taken on by pixels in image sequence.
Returns the prior probability that each individual pixel is a background pixel.
Sets the prior probability that each individual pixel is a background pixel.
“Dual TV L1” Optical Flow Algorithm.
The class implements the “Dual TV L1” optical flow algorithm described in [Zach2007] and [Javier2012] .
Here are important members of the class that control the algorithm, which you can set after constructing the class instance:
- double tau¶
Time step of the numerical scheme.
- double lambda¶
Weight parameter for the data term, attachment parameter. This is the most relevant parameter, which determines the smoothness of the output. The smaller this parameter is, the smoother the solutions we obtain. It depends on the range of motions of the images, so its value should be adapted to each image sequence.
- double theta¶
Weight parameter for (u - v)^2, tightness parameter. It serves as a link between the attachment and the regularization terms. In theory, it should have a small value in order to maintain both parts in correspondence. The method is stable for a large range of values of this parameter.
- int nscales¶
Number of scales used to create the pyramid of images.
- int warps¶
Number of warpings per scale. Represents the number of times that I1(x+u0) and grad( I1(x+u0) ) are computed per scale. This is a parameter that assures the stability of the method. It also affects the running time, so it is a compromise between speed and accuracy.
- double epsilon¶
Stopping criterion threshold used in the numerical scheme, which is a trade-off between precision and running time. A small value will yield more accurate solutions at the expense of a slower convergence.
- int iterations¶
Stopping criterion iterations number used in the numerical scheme.
Calculates an optical flow.
Parameters: |
|
---|
Releases all inner buffers.
[Bouguet00] | (1, 2) Jean-Yves Bouguet. Pyramidal Implementation of the Lucas Kanade Feature Tracker. |
[Bradski98] | Bradski, G.R. “Computer Vision Face Tracking for Use in a Perceptual User Interface”, Intel, 1998 |
[EP08] | (1, 2) Evangelidis, G.D. and Psarakis E.Z. “Parametric Image Alignment using Enhanced Correlation Coefficient Maximization”, IEEE Transactions on PAMI, vol. 32, no. 10, 2008 |
[Farneback2003] | Gunnar Farneback, Two-frame motion estimation based on polynomial expansion, Lecture Notes in Computer Science, 2003, (2749), , 363-370. |
[Horn81] | Berthold K.P. Horn and Brian G. Schunck. Determining Optical Flow. Artificial Intelligence, 17, pp. 185-203, 1981. |
[KB2001] |
|
[Javier2012] | Javier Sanchez, Enric Meinhardt-Llopis and Gabriele Facciolo. “TV-L1 Optical Flow Estimation”. |
[Lucas81] | Lucas, B., and Kanade, T. An Iterative Image Registration Technique with an Application to Stereo Vision, Proc. of 7th International Joint Conference on Artificial Intelligence (IJCAI), pp. 674-679. |
[Welch95] | Greg Welch and Gary Bishop “An Introduction to the Kalman Filter”, 1995 |
[Zach2007] |
|
[Zivkovic2004] |
|
[Zivkovic2006] | (1, 2) Z.Zivkovic, F. van der Heijden. “Efficient Adaptive Density Estimation per Image Pixel for the Task of Background Subtraction”, Pattern Recognition Letters, vol. 27, no. 7, pages 773-780, 2006. |
[Gold2012] | Andrew B. Godbehere, Akihiro Matsukawa, Ken Goldberg, “Visual Tracking of Human Visitors under Variable-Lighting Conditions for a Responsive Audio Art Installation”, American Control Conference, Montreal, June 2012. |