Merge pull request #1263 from abidrahmank:pyCLAHE_24
[profile/ivi/opencv.git] / modules / stitching / doc / high_level.rst
1 High Level Functionality
2 ========================
3
4 .. highlight:: cpp
5
6 Stitcher
7 --------
8 .. ocv:class:: Stitcher
9
10 High level image stitcher. It's possible to use this class without being aware of the entire stitching pipeline. However, to be able to achieve higher stitching stability and quality of the final images at least being familiar with the theory is recommended (see :ref:`stitching-pipeline`). ::
11
12     class CV_EXPORTS Stitcher
13     {
14     public:
15         enum { ORIG_RESOL = -1 };
16         enum Status { OK, ERR_NEED_MORE_IMGS };
17
18         // Creates stitcher with default parameters
19         static Stitcher createDefault(bool try_use_gpu = false);
20
21         Status estimateTransform(InputArray images);
22         Status estimateTransform(InputArray images, const std::vector<std::vector<Rect> > &rois);
23
24         Status composePanorama(OutputArray pano);
25         Status composePanorama(InputArray images, OutputArray pano);
26
27         Status stitch(InputArray images, OutputArray pano);
28         Status stitch(InputArray images, const std::vector<std::vector<Rect> > &rois, OutputArray pano);
29
30         double registrationResol() const { return registr_resol_; }
31         void setRegistrationResol(double resol_mpx) { registr_resol_ = resol_mpx; }
32
33         double seamEstimationResol() const { return seam_est_resol_; }
34         void setSeamEstimationResol(double resol_mpx) { seam_est_resol_ = resol_mpx; }
35
36         double compositingResol() const { return compose_resol_; }
37         void setCompositingResol(double resol_mpx) { compose_resol_ = resol_mpx; }
38
39         double panoConfidenceThresh() const { return conf_thresh_; }
40         void setPanoConfidenceThresh(double conf_thresh) { conf_thresh_ = conf_thresh; }
41
42         bool waveCorrection() const { return do_wave_correct_; }
43         void setWaveCorrection(bool flag) { do_wave_correct_ = flag; }
44
45         detail::WaveCorrectKind waveCorrectKind() const { return wave_correct_kind_; }
46         void setWaveCorrectKind(detail::WaveCorrectKind kind) { wave_correct_kind_ = kind; }
47
48         Ptr<detail::FeaturesFinder> featuresFinder() { return features_finder_; }
49         const Ptr<detail::FeaturesFinder> featuresFinder() const { return features_finder_; }
50         void setFeaturesFinder(Ptr<detail::FeaturesFinder> features_finder)
51             { features_finder_ = features_finder; }
52
53         Ptr<detail::FeaturesMatcher> featuresMatcher() { return features_matcher_; }
54         const Ptr<detail::FeaturesMatcher> featuresMatcher() const { return features_matcher_; }
55         void setFeaturesMatcher(Ptr<detail::FeaturesMatcher> features_matcher)
56             { features_matcher_ = features_matcher; }
57
58         const cv::Mat& matchingMask() const { return matching_mask_; }
59         void setMatchingMask(const cv::Mat &mask)
60         { 
61             CV_Assert(mask.type() == CV_8U && mask.cols == mask.rows);
62             matching_mask_ = mask.clone(); 
63         }
64
65         Ptr<detail::BundleAdjusterBase> bundleAdjuster() { return bundle_adjuster_; }
66         const Ptr<detail::BundleAdjusterBase> bundleAdjuster() const { return bundle_adjuster_; }
67         void setBundleAdjuster(Ptr<detail::BundleAdjusterBase> bundle_adjuster)
68             { bundle_adjuster_ = bundle_adjuster; }
69
70         Ptr<WarperCreator> warper() { return warper_; }
71         const Ptr<WarperCreator> warper() const { return warper_; }
72         void setWarper(Ptr<WarperCreator> warper) { warper_ = warper; }
73
74         Ptr<detail::ExposureCompensator> exposureCompensator() { return exposure_comp_; }
75         const Ptr<detail::ExposureCompensator> exposureCompensator() const { return exposure_comp_; }
76         void setExposureCompensator(Ptr<detail::ExposureCompensator> exposure_comp)
77             { exposure_comp_ = exposure_comp; }
78
79         Ptr<detail::SeamFinder> seamFinder() { return seam_finder_; }
80         const Ptr<detail::SeamFinder> seamFinder() const { return seam_finder_; }
81         void setSeamFinder(Ptr<detail::SeamFinder> seam_finder) { seam_finder_ = seam_finder; }
82
83         Ptr<detail::Blender> blender() { return blender_; }
84         const Ptr<detail::Blender> blender() const { return blender_; }
85         void setBlender(Ptr<detail::Blender> blender) { blender_ = blender; }
86
87     private: 
88         /* hidden */
89     };
90
91 .. note::
92
93    * A basic example on image stitching can be found at opencv_source_code/samples/cpp/stitching.cpp
94    * A detailed example on image stitching can be found at opencv_source_code/samples/cpp/stitching_detailed.cpp
95
96 Stitcher::createDefault
97 -----------------------
98 Creates a stitcher with the default parameters.
99
100 .. ocv:function:: Stitcher Stitcher::createDefault(bool try_use_gpu = false)
101
102     :param try_use_gpu: Flag indicating whether GPU should be used whenever it's possible.
103
104     :return: Stitcher class instance.
105
106 Stitcher::estimateTransform
107 ---------------------------
108
109 These functions try to match the given images and to estimate rotations of each camera.
110
111 .. note:: Use the functions only if you're aware of the stitching pipeline, otherwise use :ocv:func:`Stitcher::stitch`.
112
113 .. ocv:function:: Status Stitcher::estimateTransform(InputArray images)
114
115 .. ocv:function:: Status Stitcher::estimateTransform(InputArray images, const std::vector<std::vector<Rect> > &rois)
116
117     :param images: Input images.
118
119     :param rois: Region of interest rectangles.
120     
121     :return: Status code.
122
123 Stitcher::composePanorama
124 -------------------------
125
126 These functions try to compose the given images (or images stored internally from the other function calls) into the final pano under the assumption that the image transformations were estimated before.
127
128 .. note:: Use the functions only if you're aware of the stitching pipeline, otherwise use :ocv:func:`Stitcher::stitch`.
129
130 .. ocv:function:: Status Stitcher::composePanorama(OutputArray pano)
131
132 .. ocv:function:: Status Stitcher::composePanorama(InputArray images, OutputArray pano)
133
134     :param images: Input images.
135     
136     :param pano: Final pano.
137
138     :return: Status code.
139
140 Stitcher::stitch
141 ----------------
142
143 These functions try to stitch the given images.
144
145 .. ocv:function:: Status Stitcher::stitch(InputArray images, OutputArray pano)
146
147 .. ocv:function:: Status Stitcher::stitch(InputArray images, const std::vector<std::vector<Rect> > &rois, OutputArray pano)
148
149     :param images: Input images.
150     
151     :param rois: Region of interest rectangles.
152
153     :param pano: Final pano.
154
155     :return: Status code.
156
157 WarperCreator
158 -------------
159 .. ocv:class:: WarperCreator
160
161 Image warper factories base class. ::
162
163     class WarperCreator
164     {
165     public:
166         virtual ~WarperCreator() {}
167         virtual Ptr<detail::RotationWarper> create(float scale) const = 0;
168     };
169
170 PlaneWarper
171 -----------
172 .. ocv:class:: PlaneWarper : public WarperCreator
173
174 Plane warper factory class. ::
175
176     class PlaneWarper : public WarperCreator
177     {
178     public:
179         Ptr<detail::RotationWarper> create(float scale) const { return new detail::PlaneWarper(scale); }
180     };
181
182 .. seealso:: :ocv:class:`detail::PlaneWarper`
183
184 CylindricalWarper
185 -----------------
186 .. ocv:class:: CylindricalWarper : public WarperCreator
187
188 Cylindrical warper factory class. ::
189
190     class CylindricalWarper: public WarperCreator
191     {
192     public:
193         Ptr<detail::RotationWarper> create(float scale) const { return new detail::CylindricalWarper(scale); }
194     };
195
196 .. seealso:: :ocv:class:`detail::CylindricalWarper`
197
198 SphericalWarper
199 ---------------
200 .. ocv:class:: SphericalWarper : public WarperCreator
201
202 Spherical warper factory class. ::
203
204     class SphericalWarper: public WarperCreator
205     {
206     public:
207         Ptr<detail::RotationWarper> create(float scale) const { return new detail::SphericalWarper(scale); }
208     };
209
210 .. seealso:: :ocv:class:`detail::SphericalWarper`
211