Calculates the global motion orientation of some selected region.
:param orientation:Motion gradient orientation image; calculated by the function :ref:`CalcMotionGradient`
:type orientation::class:`CvArr`
:param mask:Mask image. It may be a conjunction of a valid gradient mask, obtained with :ref:`CalcMotionGradient` and the mask of the region, whose direction needs to be calculated
:type mask::class:`CvArr`
:param mhi:Motion history image
:type mhi::class:`CvArr`
:param timestamp:Current time in milliseconds or other units, it is better to store time passed to :ref:`UpdateMotionHistory` before and reuse it here, because running :ref:`UpdateMotionHistory` and :ref:`CalcMotionGradient` on large images may take some time
:type timestamp:float
:param duration:Maximal duration of motion track in milliseconds, the same as :ref:`UpdateMotionHistory`
:type duration:float
The function calculates the general
motion direction in the selected region and returns the angle between
0 degrees and 360 degrees . At first the function builds the orientation histogram
and finds the basic orientation as a coordinate of the histogram
maximum. After that the function calculates the shift relative to the
basic orientation as a weighted sum of all of the orientation vectors: the more
recent the motion, the greater the weight. The resultant angle is
a circular sum of the basic orientation and the shift.
Calculates the optical flow for a sparse feature set using the iterative Lucas-Kanade method with pyramids.
:param prev:First frame, at time ``t``
:type prev::class:`CvArr`
:param curr:Second frame, at time ``t + dt``
:type curr::class:`CvArr`
:param prevPyr: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
:type prevPyr::class:`CvArr`
:param currPyr:Similar to ``prevPyr`` , used for the second frame
:type currPyr::class:`CvArr`
:param prevFeatures:Array of points for which the flow needs to be found
:type prevFeatures::class:`CvPoint2D32f`
:param currFeatures:Array of 2D points containing the calculated new positions of the input features in the second image
:type currFeatures::class:`CvPoint2D32f`
:param winSize:Size of the search window of each pyramid level
:type winSize::class:`CvSize`
:param level:Maximal pyramid level number. If ``0`` , pyramids are not used (single level), if ``1`` , two levels are used, etc
:type level:int
:param status:Array. Every element of the array is set to ``1`` if the flow for the corresponding feature has been found, ``0`` otherwise
:type status:str
:param track_error:Array of double numbers containing the difference between patches around the original and moved points. Optional parameter; can be ``NULL``
:type track_error:float
:param criteria:Specifies when the iteration process of finding the flow for each point on each pyramid level should be stopped
:type criteria::class:`CvTermCriteria`
:param flags:Miscellaneous flags:
***CV_LKFLOWPyr_A_READY** pyramid for the first frame is precalculated before the call
***CV_LKFLOWPyr_B_READY** pyramid for the second frame is precalculated before the call
:type flags:int
:param guesses:optional array of estimated coordinates of features in second frame, with same length as ``prevFeatures``
:type guesses::class:`CvPoint2D32f`
The function implements the sparse iterative version of the Lucas-Kanade optical flow in pyramids
Bouguet00
. It calculates the 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.
Both parameters
``prevPyr``
and
``currPyr``
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_LKFLOWPyr_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
:param prob_image:Back projection of object histogram (see :ref:`CalcBackProject` )
:type prob_image::class:`CvArr`
:param window:Initial search window
:type window::class:`CvRect`
:param criteria:Criteria applied to determine when the window search should be finished
:type criteria::class:`CvTermCriteria`
:param comp:Resultant structure that contains the converged search window coordinates ( ``comp->rect`` field) and the sum of all of the pixels inside the window ( ``comp->area`` field)
:type comp::class:`CvConnectedComp`
:param box:Circumscribed box for the object.
:type box::class:`CvBox2D`
The function implements the CAMSHIFT object tracking algrorithm
Bradski98
.
First, it finds an object center using
:ref:`MeanShift`
and, after that, calculates the object size and orientation. The function returns number of iterations made within
:ref:`MeanShift`
.
The
``CamShiftTracker``
class declared in cv.hpp implements the color object tracker that uses the function.
\begin{array}{l l} x_k \; (x_{k-1})& \text{state of the system at the moment \emph{k} (\emph{k-1})} \\ z_k & \text{measurement of the system state at the moment \emph{k}} \\ u_k & \text{external control applied at the moment \emph{k}} \end{array}
:math:`w_k`
and
:math:`v_k`
are normally-distributed process and measurement noise, respectively:
process noise covariance matrix, constant or variable,
:math:`R`
measurement noise covariance matrix, constant or variable
In the case of the standard Kalman filter, all of the matrices: A, B, H, Q and R are initialized once after the
:ref:`CvKalman`
structure is allocated via
:ref:`CreateKalman`
. However, the same structure and the same functions may be used to simulate the extended Kalman filter by linearizing the extended Kalman filter equation in the current system state neighborhood, in this case A, B, H (and, probably, Q and R) should be updated on every step.
:math:`x_{k-1}` is corrected state on the previous step ``kalman->state_post`` (should be initialized somehow in the beginning, zero vector by default), \
:math:`u_k` is external control ( ``control`` parameter), \
:math:`P'_k` is priori error covariance matrix ``kalman->error_cov_pre`` \
:math:`P_{k-1}` is posteriori error covariance matrix on the previous step ``kalman->error_cov_post`` (should be initialized somehow in the beginning, identity matrix by default),
:param prob_image:Back projection of the object histogram (see :ref:`CalcBackProject` )
:type prob_image::class:`CvArr`
:param window:Initial search window
:type window::class:`CvRect`
:param criteria:Criteria applied to determine when the window search should be finished
:type criteria::class:`CvTermCriteria`
:param comp:Resultant structure that contains the converged search window coordinates ( ``comp->rect`` field) and the sum of all of the pixels inside the window ( ``comp->area`` field)
:type comp::class:`CvConnectedComp`
The function iterates to find the object center
given its back projection and initial position of search window. The
iterations are made until the search window center moves by less than
the given value and/or until the function has done the maximum number
of iterations. The function returns the number of iterations made.
Changes the contour position to minimize its energy.
:param image:The source image or external energy field
:type image::class:`IplImage`
:param points:Contour points (snake)
:type points::class:`CvPoints`
:param alpha:Weight[s] of continuity energy, single float or
a list of floats, one for each contour point
:type alpha:sequence of float
:param beta:Weight[s] of curvature energy, similar to ``alpha``
:type beta:sequence of float
:param gamma:Weight[s] of image energy, similar to ``alpha``
:type gamma:sequence of float
:param win:Size of neighborhood of every point used to search the minimum, both ``win.width`` and ``win.height`` must be odd
:type win::class:`CvSize`
:param criteria:Termination criteria
:type criteria::class:`CvTermCriteria`
:param calc_gradient:Gradient flag; if not 0, the function calculates the gradient magnitude for every image pixel and consideres it as the energy field, otherwise the input image itself is considered
:type calc_gradient:int
The function updates the snake in order to minimize its
total energy that is a sum of internal energy that depends on the contour
shape (the smoother contour is, the smaller internal energy is) and
external energy that depends on the energy field and reaches minimum at
the local energy extremums that correspond to the image edges in the case
of using an image gradient.
The parameter
``criteria.epsilon``
is used to define the minimal
number of points that must be moved during any iteration to keep the
iteration process running.
If at some iteration the number of moved points is less