Merge pull request #2887 from ilya-lavrenov:ipp_morph_fix
[platform/upstream/opencv.git] / modules / contrib / doc / stereo.rst
1 Stereo Correspondence
2 ========================================
3
4 .. highlight:: cpp
5
6 StereoVar
7 ----------
8
9 .. ocv:class:: StereoVar
10
11 Class for computing stereo correspondence using the variational matching algorithm ::
12
13     class StereoVar
14     {
15         StereoVar();
16         StereoVar(    int levels, double pyrScale,
17                                         int nIt, int minDisp, int maxDisp,
18                                         int poly_n, double poly_sigma, float fi,
19                                         float lambda, int penalization, int cycle,
20                                         int flags);
21         virtual ~StereoVar();
22
23         virtual void operator()(InputArray left, InputArray right, OutputArray disp);
24
25         int        levels;
26         double    pyrScale;
27         int        nIt;
28         int        minDisp;
29         int        maxDisp;
30         int        poly_n;
31         double    poly_sigma;
32         float    fi;
33         float    lambda;
34         int        penalization;
35         int        cycle;
36         int        flags;
37
38         ...
39     };
40
41 The class implements the modified S. G. Kosov algorithm [Publication] that differs from the original one as follows:
42
43  * The automatic initialization of method's parameters is added.
44
45  * The method of Smart Iteration Distribution (SID) is implemented.
46
47  * The support of Multi-Level Adaptation Technique (MLAT) is not included.
48
49  * The method of dynamic adaptation of method's parameters is not included.
50
51 StereoVar::StereoVar
52 --------------------------
53
54 .. ocv:function:: StereoVar::StereoVar()
55
56 .. ocv:function:: StereoVar::StereoVar( int levels, double pyrScale, int nIt, int minDisp, int maxDisp, int poly_n, double poly_sigma, float fi, float lambda, int penalization, int cycle, int flags )
57
58     The constructor
59
60     :param levels: The number of pyramid layers, including the initial image. levels=1 means that no extra layers are created and only the original images are used. This parameter is ignored if flag USE_AUTO_PARAMS is set.
61
62     :param pyrScale: Specifies the image scale (<1) to build the pyramids for each image. pyrScale=0.5 means the classical pyramid, where each next layer is twice smaller than the previous. (This parameter is ignored if flag USE_AUTO_PARAMS is set).
63
64     :param nIt: The number of iterations the algorithm does at each pyramid level. (If the flag USE_SMART_ID is set, the number of iterations will be redistributed in such a way, that more iterations will be done on more coarser levels.)
65
66     :param minDisp: Minimum possible disparity value. Could be negative in case the left and right input images change places.
67
68     :param maxDisp: Maximum possible disparity value.
69
70     :param poly_n: Size of the pixel neighbourhood used to find polynomial expansion in each pixel. The larger values mean that the image will be approximated with smoother surfaces, yielding more robust algorithm and more blurred motion field. Typically, poly_n = 3, 5 or 7
71
72     :param poly_sigma: Standard deviation of the Gaussian that is used to smooth derivatives that are used as a basis for the polynomial expansion. For poly_n=5 you can set poly_sigma=1.1 , for poly_n=7 a good value would be poly_sigma=1.5
73
74     :param fi: The smoothness parameter, ot the weight coefficient for the smoothness term.
75
76     :param lambda: The threshold parameter for edge-preserving smoothness. (This parameter is ignored if PENALIZATION_CHARBONNIER or PENALIZATION_PERONA_MALIK is used.)
77
78     :param penalization: Possible values: PENALIZATION_TICHONOV - linear smoothness; PENALIZATION_CHARBONNIER - non-linear edge preserving smoothness; PENALIZATION_PERONA_MALIK - non-linear edge-enhancing smoothness. (This parameter is ignored if flag USE_AUTO_PARAMS is set).
79
80     :param cycle: Type of the multigrid cycle. Possible values: CYCLE_O and CYCLE_V for null- and v-cycles respectively. (This parameter is ignored if flag USE_AUTO_PARAMS is set).
81
82     :param flags: The operation flags; can be a combination of the following:
83
84         * USE_INITIAL_DISPARITY: Use the input flow as the initial flow approximation.
85
86         * USE_EQUALIZE_HIST: Use the histogram equalization in the pre-processing phase.
87
88         * USE_SMART_ID: Use the smart iteration distribution (SID).
89
90         * USE_AUTO_PARAMS: Allow the method to initialize the main parameters.
91
92         * USE_MEDIAN_FILTERING: Use the median filer of the solution in the post processing phase.
93
94 The first constructor initializes ``StereoVar`` with all the default parameters. So, you only have to set ``StereoVar::maxDisp`` and / or ``StereoVar::minDisp`` at minimum. The second constructor enables you to set each parameter to a custom value.
95
96
97
98 StereoVar::operator ()
99 -----------------------
100
101 .. ocv:function:: void StereoVar::operator()( const Mat& left, const Mat& right, Mat& disp )
102
103     Computes disparity using the variational algorithm for a rectified stereo pair.
104
105     :param left: Left 8-bit single-channel or 3-channel image.
106
107     :param right: Right image of the same size and the same type as the left one.
108
109     :param disp: Output disparity map. It is a 8-bit signed single-channel image of the same size as the input image.
110
111 The method executes the variational algorithm on a rectified stereo pair. See ``stereo_match.cpp`` OpenCV sample on how to prepare images and call the method.
112
113 **Note**:
114
115 The method is not constant, so you should not use the same ``StereoVar`` instance from different threads simultaneously.