2011-02-22 21:43:26 +01:00
Motion Analysis and Object Tracking
===================================
2011-04-19 13:41:12 +02:00
.. highlight :: cpp
2011-02-28 22:26:43 +01:00
accumulate
2011-02-22 21:43:26 +01:00
--------------
2011-06-30 00:06:42 +02:00
Adds an image to the accumulator.
2011-06-16 14:48:23 +02:00
.. ocv:function :: void accumulate( InputArray src, InputOutputArray dst, InputArray mask=noArray() )
2011-02-22 21:43:26 +01:00
2011-07-16 11:35:56 +02:00
.. ocv:pyfunction :: cv2.accumulate(src, dst[, mask]) -> None
2011-06-30 00:06:42 +02:00
2012-05-28 09:36:14 +02:00
.. ocv:cfunction :: void cvAcc( const CvArr* image, CvArr* sum, const CvArr* mask=NULL )
.. ocv:pyoldfunction :: cv.Acc(image, sum, mask=None) -> None
2011-02-22 21:43:26 +01:00
2011-04-24 23:02:14 +02:00
:param src: Input image as 1- or 3-channel, 8-bit or 32-bit floating point.
2011-02-22 21:43:26 +01:00
2011-04-24 23:02:14 +02:00
:param dst: Accumulator image with the same number of channels as input image, 32-bit or 64-bit floating-point.
2011-02-22 21:43:26 +01:00
2011-04-24 23:02:14 +02:00
:param mask: Optional operation mask.
2011-02-22 21:43:26 +01:00
2011-04-24 23:02:14 +02:00
The function adds `` src `` or some of its elements to `` dst `` :
2011-02-22 21:43:26 +01:00
.. math ::
2011-02-26 12:05:10 +01:00
\texttt{dst} (x,y) \leftarrow \texttt{dst} (x,y) + \texttt{src} (x,y) \quad \text{if} \quad \texttt{mask} (x,y) \ne 0
2011-02-22 21:43:26 +01:00
2011-04-24 23:02:14 +02:00
The function supports multi-channel images. Each channel is processed independently.
2011-02-22 21:43:26 +01:00
2011-04-24 23:02:14 +02:00
The functions `` accumulate* `` can be used, for example, to collect statistics of a scene background viewed by a still camera and for the further foreground-background segmentation.
2011-02-22 21:43:26 +01:00
2011-06-30 00:06:42 +02:00
.. seealso ::
2011-07-01 14:09:39 +02:00
:ocv:func: `accumulateSquare` ,
:ocv:func: `accumulateProduct` ,
:ocv:func: `accumulateWeighted`
2011-04-30 15:52:10 +02:00
2011-06-30 00:06:42 +02:00
2011-02-22 21:43:26 +01:00
2011-02-28 22:26:43 +01:00
accumulateSquare
2011-02-22 21:43:26 +01:00
--------------------
2011-06-30 00:06:42 +02:00
Adds the square of a source image to the accumulator.
2011-06-16 14:48:23 +02:00
.. ocv:function :: void accumulateSquare( InputArray src, InputOutputArray dst, InputArray mask=noArray() )
2011-02-22 21:43:26 +01:00
2011-07-16 11:35:56 +02:00
.. ocv:pyfunction :: cv2.accumulateSquare(src, dst[, mask]) -> None
2011-06-30 00:06:42 +02:00
2012-05-28 09:36:14 +02:00
.. ocv:cfunction :: void cvSquareAcc( const CvArr* image, CvArr* sqsum, const CvArr* mask=NULL )
.. ocv:pyoldfunction :: cv.SquareAcc(image, sqsum, mask=None) -> None
2011-02-22 21:43:26 +01:00
2011-04-24 23:02:14 +02:00
:param src: Input image as 1- or 3-channel, 8-bit or 32-bit floating point.
2011-02-22 21:43:26 +01:00
2011-04-24 23:02:14 +02:00
:param dst: Accumulator image with the same number of channels as input image, 32-bit or 64-bit floating-point.
2011-02-22 21:43:26 +01:00
2011-04-24 23:02:14 +02:00
:param mask: Optional operation mask.
2011-02-22 21:43:26 +01:00
2011-06-30 00:06:42 +02:00
The function adds the input image `` src `` or its selected region, raised to a power of 2, to the accumulator `` dst `` :
2011-02-22 21:43:26 +01:00
.. math ::
2011-02-26 12:05:10 +01:00
\texttt{dst} (x,y) \leftarrow \texttt{dst} (x,y) + \texttt{src} (x,y)^2 \quad \text{if} \quad \texttt{mask} (x,y) \ne 0
2011-02-22 21:43:26 +01:00
2011-06-30 00:06:42 +02:00
The function supports multi-channel images. Each channel is processed independently.
2011-04-24 23:02:14 +02:00
2011-06-30 00:06:42 +02:00
.. seealso ::
2011-07-01 11:39:22 +02:00
:ocv:func: `accumulateSquare` ,
:ocv:func: `accumulateProduct` ,
:ocv:func: `accumulateWeighted`
2011-02-22 21:43:26 +01:00
2011-06-30 00:06:42 +02:00
2011-02-22 21:43:26 +01:00
2011-02-28 22:26:43 +01:00
accumulateProduct
2011-02-22 21:43:26 +01:00
---------------------
2011-06-30 00:06:42 +02:00
Adds the per-element product of two input images to the accumulator.
2011-06-16 14:48:23 +02:00
.. ocv:function :: void accumulateProduct( InputArray src1, InputArray src2, InputOutputArray dst, InputArray mask=noArray() )
2011-02-22 21:43:26 +01:00
2011-07-16 11:35:56 +02:00
.. ocv:pyfunction :: cv2.accumulateProduct(src1, src2, dst[, mask]) -> None
2011-06-30 00:06:42 +02:00
2012-05-28 09:36:14 +02:00
.. ocv:cfunction :: void cvMultiplyAcc( const CvArr* image1, const CvArr* image2, CvArr* acc, const CvArr* mask=NULL )
.. ocv:pyoldfunction :: cv.MultiplyAcc(image1, image2, acc, mask=None)-> None
2011-02-22 21:43:26 +01:00
2011-06-30 00:06:42 +02:00
:param src1: First input image, 1- or 3-channel, 8-bit or 32-bit floating point.
2011-02-22 21:43:26 +01:00
2011-06-30 00:06:42 +02:00
:param src2: Second input image of the same type and the same size as ``src1`` .
2012-05-28 09:36:14 +02:00
2011-04-24 23:02:14 +02:00
:param dst: Accumulator with the same number of channels as input images, 32-bit or 64-bit floating-point.
2011-02-22 21:43:26 +01:00
2011-04-24 23:02:14 +02:00
:param mask: Optional operation mask.
2011-02-22 21:43:26 +01:00
2011-06-30 00:06:42 +02:00
The function adds the product of two images or their selected regions to the accumulator `` dst `` :
2011-02-22 21:43:26 +01:00
.. math ::
2011-02-26 12:05:10 +01:00
\texttt{dst} (x,y) \leftarrow \texttt{dst} (x,y) + \texttt{src1} (x,y) \cdot \texttt{src2} (x,y) \quad \text{if} \quad \texttt{mask} (x,y) \ne 0
2011-02-22 21:43:26 +01:00
2011-04-24 23:02:14 +02:00
The function supports multi-channel images. Each channel is processed independently.
2011-06-30 00:06:42 +02:00
.. seealso ::
2011-07-01 11:39:22 +02:00
:ocv:func: `accumulate` ,
:ocv:func: `accumulateSquare` ,
:ocv:func: `accumulateWeighted`
2011-02-22 21:43:26 +01:00
2011-06-30 00:06:42 +02:00
2011-02-22 21:43:26 +01:00
2011-02-28 22:26:43 +01:00
accumulateWeighted
2011-02-22 21:43:26 +01:00
----------------------
2011-06-30 00:06:42 +02:00
Updates a running average.
2011-06-16 14:48:23 +02:00
.. ocv:function :: void accumulateWeighted( InputArray src, InputOutputArray dst, double alpha, InputArray mask=noArray() )
2011-02-22 21:43:26 +01:00
2011-07-16 11:35:56 +02:00
.. ocv:pyfunction :: cv2.accumulateWeighted(src, dst, alpha[, mask]) -> None
2011-06-30 00:06:42 +02:00
2012-05-28 09:36:14 +02:00
.. ocv:cfunction :: void cvRunningAvg( const CvArr* image, CvArr* acc, double alpha, const CvArr* mask=NULL )
.. ocv:pyoldfunction :: cv.RunningAvg(image, acc, alpha, mask=None)-> None
2011-02-22 21:43:26 +01:00
2011-04-24 23:02:14 +02:00
:param src: Input image as 1- or 3-channel, 8-bit or 32-bit floating point.
2011-02-22 21:43:26 +01:00
2011-04-24 23:02:14 +02:00
:param dst: Accumulator image with the same number of channels as input image, 32-bit or 64-bit floating-point.
2011-02-22 21:43:26 +01:00
2011-04-24 23:02:14 +02:00
:param alpha: Weight of the input image.
2011-02-22 21:43:26 +01:00
2011-04-24 23:02:14 +02:00
:param mask: Optional operation mask.
2011-02-22 21:43:26 +01:00
2011-04-24 23:02:14 +02:00
The function calculates the weighted sum of the input image `` src `` and the accumulator `` dst `` so that `` dst `` becomes a running average of a frame sequence:
2011-02-22 21:43:26 +01:00
.. math ::
2011-02-26 12:05:10 +01:00
\texttt{dst} (x,y) \leftarrow (1- \texttt{alpha} ) \cdot \texttt{dst} (x,y) + \texttt{alpha} \cdot \texttt{src} (x,y) \quad \text{if} \quad \texttt{mask} (x,y) \ne 0
2011-02-22 21:43:26 +01:00
2011-04-24 23:02:14 +02:00
That is, `` alpha `` regulates the update speed (how fast the accumulator "forgets" about earlier images).
The function supports multi-channel images. Each channel is processed independently.
2011-02-22 21:43:26 +01:00
2011-06-30 00:06:42 +02:00
.. seealso ::
2011-07-01 11:39:22 +02:00
:ocv:func: `accumulate` ,
:ocv:func: `accumulateSquare` ,
2012-05-28 09:36:14 +02:00
:ocv:func: `accumulateProduct`
2011-09-05 09:57:18 +02:00
phaseCorrelate
2012-03-29 08:50:05 +02:00
--------------
2012-04-13 23:50:59 +02:00
The function is used to detect translational shifts that occur between two images. The operation takes advantage of the Fourier shift theorem for detecting the translational shift in the frequency domain. It can be used for fast image registration as well as motion estimation. For more information please see http://en.wikipedia.org/wiki/Phase\_correlation .
2011-09-05 09:57:18 +02:00
2012-03-29 08:50:05 +02:00
Calculates the cross-power spectrum of two supplied source arrays. The arrays are padded if needed with :ocv:func: `getOptimalDFTSize` .
2011-09-05 09:57:18 +02:00
.. ocv:function :: Point2d phaseCorrelate(InputArray src1, InputArray src2, InputArray window = noArray())
2011-09-15 10:31:14 +02:00
2011-09-05 09:57:18 +02:00
:param src1: Source floating point array (CV_32FC1 or CV_64FC1)
:param src2: Source floating point array (CV_32FC1 or CV_64FC1)
:param window: Floating point array with windowing coefficients to reduce edge effects (optional).
2012-03-29 08:50:05 +02:00
Return value: detected phase shift (sub-pixel) between the two arrays.
2011-09-05 09:57:18 +02:00
The function performs the following equations
*
First it applies a Hanning window (see http://en.wikipedia.org/wiki/Hann\_function) to each image to remove possible edge effects. This window is cached until the array size changes to speed up processing time.
*
Next it computes the forward DFTs of each source array:
2011-09-12 17:28:04 +02:00
.. math ::
2012-03-02 21:59:13 +01:00
2011-09-05 09:57:18 +02:00
\mathbf{G}_a = \mathcal{F}\{src_1\}, \; \mathbf{G}_b = \mathcal{F}\{src_2\}
2012-03-02 21:59:13 +01:00
2011-09-05 09:57:18 +02:00
where
2011-09-12 17:28:04 +02:00
:math: `\mathcal{F}` is the forward DFT.
2011-09-05 09:57:18 +02:00
*
It then computes the cross-power spectrum of each frequency domain array:
2011-09-12 17:28:04 +02:00
.. math ::
2012-03-02 21:59:13 +01:00
2011-09-05 09:57:18 +02:00
R = \frac{ \mathbf{G}_a \mathbf{G}_b^*}{|\mathbf{G}_a \mathbf{G}_b^* |}
*
Next the cross-correlation is converted back into the time domain via the inverse DFT:
2011-09-12 17:28:04 +02:00
.. math ::
2012-03-02 21:59:13 +01:00
2011-09-05 09:57:18 +02:00
r = \mathcal{F}^{-1}\{R\}
*
Finally, it computes the peak location and computes a 5x5 weighted centroid around the peak to achieve sub-pixel accuracy.
2011-09-12 17:28:04 +02:00
.. math ::
2012-03-02 21:59:13 +01:00
(\Delta x, \Delta y) = \texttt{weighted_centroid}\{\arg \max_{(x, y)}\{r\}\}
2011-09-05 09:57:18 +02:00
.. seealso ::
:ocv:func: `dft` ,
:ocv:func: `getOptimalDFTSize` ,
:ocv:func: `idft` ,
:ocv:func: `mulSpectrums`
:ocv:func: `createHanningWindow`
createHanningWindow
-------------------------------
This function computes a Hanning window coefficients in two dimensions. See http://en.wikipedia.org/wiki/Hann\_function and http://en.wikipedia.org/wiki/Window\_function for more information.
.. ocv:function :: void createHanningWindow(OutputArray dst, Size winSize, int type)
2011-09-15 10:31:14 +02:00
2011-09-05 09:57:18 +02:00
:param dst: Destination array to place Hann coefficients in
:param winSize: The window size specifications
:param type: Created array type
2011-09-12 17:28:04 +02:00
An example is shown below: ::
2012-05-28 09:36:14 +02:00
// create hanning window of size 100x100 and type CV_32F
2011-09-05 09:57:18 +02:00
Mat hann;
createHanningWindow(hann, Size(100, 100), CV_32F);
.. seealso ::
:ocv:func: `phaseCorrelate`