File: motion_analysis.rst

package info (click to toggle)
opencv 2.4.9.1%2Bdfsg-1%2Bdeb8u1
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 126,800 kB
  • ctags: 62,729
  • sloc: xml: 509,055; cpp: 490,794; lisp: 23,208; python: 21,174; java: 19,317; ansic: 1,038; sh: 128; makefile: 72
file content (86 lines) | stat: -rw-r--r-- 4,245 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
Motion Analysis
===============

.. highlight:: cpp


CalcOpticalFlowBM
-----------------
Calculates the optical flow for two images by using the block matching method.

.. ocv:cfunction:: void cvCalcOpticalFlowBM( const CvArr* prev, const CvArr* curr, CvSize block_size, CvSize shift_size, CvSize max_range, int use_previous, CvArr* velx, CvArr* vely )

.. ocv:pyoldfunction:: cv.CalcOpticalFlowBM(prev, curr, blockSize, shiftSize, max_range, usePrevious, velx, vely)-> None

        :param prev: First image, 8-bit, single-channel

        :param curr: Second image, 8-bit, single-channel

        :param block_size: Size of basic blocks that are compared

        :param shift_size: Block coordinate increments

        :param max_range: Size of the scanned neighborhood in pixels around the block

        :param use_previous: Flag that specifies whether to use the input velocity as initial approximations or not.

        :param velx: Horizontal component of the optical flow of

            .. math::

                \left \lfloor   \frac{\texttt{prev->width} - \texttt{block\_size.width}}{\texttt{shift\_size.width}}   \right \rfloor \times \left \lfloor   \frac{\texttt{prev->height} - \texttt{block\_size.height}}{\texttt{shift\_size.height}}   \right \rfloor

            size, 32-bit floating-point, single-channel

        :param vely: Vertical component of the optical flow of the same size  ``velx`` , 32-bit floating-point, single-channel


The function calculates the optical flow for overlapped blocks ``block_size.width x block_size.height`` pixels each, thus the velocity fields are smaller than the original images. For every block in  ``prev``
the functions tries to find a similar block in ``curr`` in some neighborhood of the original block or shifted by ``(velx(x0,y0), vely(x0,y0))`` block as has been calculated by previous function call (if ``use_previous=1``)


CalcOpticalFlowHS
-----------------
Calculates the optical flow for two images using Horn-Schunck algorithm.

.. ocv:cfunction:: void cvCalcOpticalFlowHS(const CvArr* prev, const CvArr* curr, int use_previous, CvArr* velx, CvArr* vely, double lambda, CvTermCriteria criteria)

.. ocv:pyoldfunction:: cv.CalcOpticalFlowHS(prev, curr, usePrevious, velx, vely, lambda, criteria)-> None

    :param prev: First image, 8-bit, single-channel

    :param curr: Second image, 8-bit, single-channel

    :param use_previous: Flag that specifies whether to use the input velocity as initial approximations or not.

    :param velx: Horizontal component of the optical flow of the same size as input images, 32-bit floating-point, single-channel

    :param vely: Vertical component of the optical flow of the same size as input images, 32-bit floating-point, single-channel

    :param lambda: Smoothness weight. The larger it is, the smoother optical flow map you get.

    :param criteria: Criteria of termination of velocity computing

The function computes the flow for every pixel of the first input image using the Horn and Schunck algorithm [Horn81]_. The function is obsolete. To track sparse features, use :ocv:func:`calcOpticalFlowPyrLK`. To track all the pixels, use :ocv:func:`calcOpticalFlowFarneback`.


CalcOpticalFlowLK
-----------------

Calculates the optical flow for two images using Lucas-Kanade algorithm.

.. ocv:cfunction:: void cvCalcOpticalFlowLK( const CvArr* prev, const CvArr* curr, CvSize win_size, CvArr* velx, CvArr* vely )

.. ocv:pyoldfunction:: cv.CalcOpticalFlowLK(prev, curr, winSize, velx, vely)-> None

    :param prev: First image, 8-bit, single-channel

    :param curr: Second image, 8-bit, single-channel

    :param win_size: Size of the averaging window used for grouping pixels

    :param velx: Horizontal component of the optical flow of the same size as input images, 32-bit floating-point, single-channel

    :param vely: Vertical component of the optical flow of the same size as input images, 32-bit floating-point, single-channel

The function computes the flow for every pixel of the first input image using the Lucas and Kanade algorithm [Lucas81]_. The function is obsolete. To track sparse features, use :ocv:func:`calcOpticalFlowPyrLK`. To track all the pixels, use :ocv:func:`calcOpticalFlowFarneback`.