OpenCV 4.5.3(日本語機械翻訳)
stitching.hpp
1 /*M///////////////////////////////////////////////////////////////////////////////////////
2 //
3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4 //
5 // By downloading, copying, installing or using the software you agree to this license.
6 // If you do not agree to this license, do not download, install,
7 // copy or use the software.
8 //
9 //
10 // License Agreement
11 // For Open Source Computer Vision Library
12 //
13 // Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
14 // Copyright (C) 2009, Willow Garage Inc., all rights reserved.
15 // Third party copyrights are property of their respective owners.
16 //
17 // Redistribution and use in source and binary forms, with or without modification,
18 // are permitted provided that the following conditions are met:
19 //
20 // * Redistribution's of source code must retain the above copyright notice,
21 // this list of conditions and the following disclaimer.
22 //
23 // * Redistribution's in binary form must reproduce the above copyright notice,
24 // this list of conditions and the following disclaimer in the documentation
25 // and/or other materials provided with the distribution.
26 //
27 // * The name of the copyright holders may not be used to endorse or promote products
28 // derived from this software without specific prior written permission.
29 //
30 // This software is provided by the copyright holders and contributors "as is" and
31 // any express or implied warranties, including, but not limited to, the implied
32 // warranties of merchantability and fitness for a particular purpose are disclaimed.
33 // In no event shall the Intel Corporation or contributors be liable for any direct,
34 // indirect, incidental, special, exemplary, or consequential damages
35 // (including, but not limited to, procurement of substitute goods or services;
36 // loss of use, data, or profits; or business interruption) however caused
37 // and on any theory of liability, whether in contract, strict liability,
38 // or tort (including negligence or otherwise) arising in any way out of
39 // the use of this software, even if advised of the possibility of such damage.
40 //
41 //M*/
42
43 #ifndef OPENCV_STITCHING_STITCHER_HPP
44 #define OPENCV_STITCHING_STITCHER_HPP
45
46 #include "opencv2/core.hpp"
47 #include "opencv2/features2d.hpp"
48 #include "opencv2/stitching/warpers.hpp"
49 #include "opencv2/stitching/detail/matchers.hpp"
50 #include "opencv2/stitching/detail/motion_estimators.hpp"
51 #include "opencv2/stitching/detail/exposure_compensate.hpp"
52 #include "opencv2/stitching/detail/seam_finders.hpp"
53 #include "opencv2/stitching/detail/blenders.hpp"
54 #include "opencv2/stitching/detail/camera.hpp"
55
56
57 #if defined(Status)
58 # warning Detected X11 'Status' macro definition, it can cause build conflicts. Please, include this header before any X11 headers.
59 #endif
60
61
107 namespace cv {
108
111
138 class CV_EXPORTS_W Stitcher
139{
140 public:
145 #if __cplusplus >= 201103L || (defined(_MSC_VER) && _MSC_VER >= 1900 /*MSVS 2015*/ )
146 static constexpr double ORIG_RESOL = -1.0;
147 #else
148 // support MSVS 2013
149 static const double ORIG_RESOL; // Initialized in stitcher.cpp
150 #endif
151
152 enum Status
153 {
154 OK = 0,
155 ERR_NEED_MORE_IMGS = 1,
156 ERR_HOMOGRAPHY_EST_FAIL = 2,
157 ERR_CAMERA_PARAMS_ADJUST_FAIL = 3
158 };
159
160 enum Mode
161 {
167 PANORAMA = 0,
173 SCANS = 1,
174
175 };
176
184 CV_WRAP static Ptr<Stitcher> create(Mode mode = Stitcher::PANORAMA);
185
186 CV_WRAP double registrationResol() const { return registr_resol_; }
187 CV_WRAP void setRegistrationResol(double resol_mpx) { registr_resol_ = resol_mpx; }
188
189 CV_WRAP double seamEstimationResol() const { return seam_est_resol_; }
190 CV_WRAP void setSeamEstimationResol(double resol_mpx) { seam_est_resol_ = resol_mpx; }
191
192 CV_WRAP double compositingResol() const { return compose_resol_; }
193 CV_WRAP void setCompositingResol(double resol_mpx) { compose_resol_ = resol_mpx; }
194
195 CV_WRAP double panoConfidenceThresh() const { return conf_thresh_; }
196 CV_WRAP void setPanoConfidenceThresh(double conf_thresh) { conf_thresh_ = conf_thresh; }
197
198 CV_WRAP bool waveCorrection() const { return do_wave_correct_; }
199 CV_WRAP void setWaveCorrection(bool flag) { do_wave_correct_ = flag; }
200
201 CV_WRAP InterpolationFlags interpolationFlags() const { return interp_flags_; }
202 CV_WRAP void setInterpolationFlags(InterpolationFlags interp_flags) { interp_flags_ = interp_flags; }
203
204 detail::WaveCorrectKind waveCorrectKind() const { return wave_correct_kind_; }
205 void setWaveCorrectKind(detail::WaveCorrectKind kind) { wave_correct_kind_ = kind; }
206
207 Ptr<Feature2D> featuresFinder() { return features_finder_; }
208 const Ptr<Feature2D> featuresFinder() const { return features_finder_; }
209 void setFeaturesFinder(Ptr<Feature2D> features_finder)
210 { features_finder_ = features_finder; }
211
212 Ptr<detail::FeaturesMatcher> featuresMatcher() { return features_matcher_; }
213 const Ptr<detail::FeaturesMatcher> featuresMatcher() const { return features_matcher_; }
214 void setFeaturesMatcher(Ptr<detail::FeaturesMatcher> features_matcher)
215 { features_matcher_ = features_matcher; }
216
217 const cv::UMat& matchingMask() const { return matching_mask_; }
218 void setMatchingMask(const cv::UMat &mask)
219 {
220 CV_Assert(mask.type() == CV_8U && mask.cols == mask.rows);
221 matching_mask_ = mask.clone();
222 }
223
224 Ptr<detail::BundleAdjusterBase> bundleAdjuster() { return bundle_adjuster_; }
225 const Ptr<detail::BundleAdjusterBase> bundleAdjuster() const { return bundle_adjuster_; }
226 void setBundleAdjuster(Ptr<detail::BundleAdjusterBase> bundle_adjuster)
227 { bundle_adjuster_ = bundle_adjuster; }
228
229 Ptr<detail::Estimator> estimator() { return estimator_; }
230 const Ptr<detail::Estimator> estimator() const { return estimator_; }
231 void setEstimator(Ptr<detail::Estimator> estimator)
232 { estimator_ = estimator; }
233
234 Ptr<WarperCreator> warper() { return warper_; }
235 const Ptr<WarperCreator> warper() const { return warper_; }
236 void setWarper(Ptr<WarperCreator> creator) { warper_ = creator; }
237
238 Ptr<detail::ExposureCompensator> exposureCompensator() { return exposure_comp_; }
239 const Ptr<detail::ExposureCompensator> exposureCompensator() const { return exposure_comp_; }
240 void setExposureCompensator(Ptr<detail::ExposureCompensator> exposure_comp)
241 { exposure_comp_ = exposure_comp; }
242
243 Ptr<detail::SeamFinder> seamFinder() { return seam_finder_; }
244 const Ptr<detail::SeamFinder> seamFinder() const { return seam_finder_; }
245 void setSeamFinder(Ptr<detail::SeamFinder> seam_finder) { seam_finder_ = seam_finder; }
246
247 Ptr<detail::Blender> blender() { return blender_; }
248 const Ptr<detail::Blender> blender() const { return blender_; }
249 void setBlender(Ptr<detail::Blender> b) { blender_ = b; }
250
260 CV_WRAP Status estimateTransform(InputArrayOfArrays images, InputArrayOfArrays masks = noArray());
261
270 Status setTransform(InputArrayOfArrays images,
271 const std::vector<detail::CameraParams> &cameras,
272 const std::vector<int> &component);
274 Status setTransform(InputArrayOfArrays images, const std::vector<detail::CameraParams> &cameras);
275
277 CV_WRAP Status composePanorama(OutputArray pano);
289 CV_WRAP Status composePanorama(InputArrayOfArrays images, OutputArray pano);
290
292 CV_WRAP Status stitch(InputArrayOfArrays images, OutputArray pano);
300 CV_WRAP Status stitch(InputArrayOfArrays images, InputArrayOfArrays masks, OutputArray pano);
301
302 std::vector<int> component() const { return indices_; }
303 std::vector<detail::CameraParams> cameras() const { return cameras_; }
304 CV_WRAP double workScale() const { return work_scale_; }
305 UMat resultMask() const { return result_mask_; }
306
307 private:
308 Status matchImages();
309 Status estimateCameraParams();
310
311 double registr_resol_;
312 double seam_est_resol_;
313 double compose_resol_;
314 double conf_thresh_;
315 InterpolationFlags interp_flags_;
316 Ptr<Feature2D> features_finder_;
317 Ptr<detail::FeaturesMatcher> features_matcher_;
318 cv::UMat matching_mask_;
319 Ptr<detail::BundleAdjusterBase> bundle_adjuster_;
320 Ptr<detail::Estimator> estimator_;
321 bool do_wave_correct_;
322 detail::WaveCorrectKind wave_correct_kind_;
323 Ptr<WarperCreator> warper_;
324 Ptr<detail::ExposureCompensator> exposure_comp_;
325 Ptr<detail::SeamFinder> seam_finder_;
326 Ptr<detail::Blender> blender_;
327
328 std::vector<cv::UMat> imgs_;
329 std::vector<cv::UMat> masks_;
330 std::vector<cv::Size> full_img_sizes_;
331 std::vector<detail::ImageFeatures> features_;
332 std::vector<detail::MatchesInfo> pairwise_matches_;
333 std::vector<cv::UMat> seam_est_imgs_;
334 std::vector<int> indices_;
335 std::vector<detail::CameraParams> cameras_;
336 UMat result_mask_;
337 double work_scale_;
338 double seam_scale_;
339 double seam_work_aspect_;
340 double warped_image_scale_;
341};
342
346 CV_DEPRECATED Ptr<Stitcher> createStitcher(bool try_use_gpu = false);
347
351 CV_DEPRECATED Ptr<Stitcher> createStitcherScans(bool try_use_gpu = false);
352
354
355} // namespace cv
356
357 #endif // OPENCV_STITCHING_STITCHER_HPP
This type is very similar to InputArray except that it is used for input/output and output function p...
Definition: mat.hpp:295
High level image stitcher.
Definition: stitching.hpp:139
Mode
Definition: stitching.hpp:161
@ PANORAMA
Definition: stitching.hpp:167
Status setTransform(InputArrayOfArrays images, const std::vector< detail::CameraParams > &cameras)
static const double ORIG_RESOL
Definition: stitching.hpp:149
Status setTransform(InputArrayOfArrays images, const std::vector< detail::CameraParams > &cameras, const std::vector< int > &component)
These function restors camera rotation and camera intrinsics of each camera that can be got with Stit...
Definition: mat.hpp:2402
#define CV_Assert(expr)
Checks a condition at runtime and throws exception if it fails
Definition: base.hpp:342
InterpolationFlags
interpolation algorithm
Definition: imgproc.hpp:245
CV_DEPRECATED Ptr< Stitcher > createStitcher(bool try_use_gpu=false)
CV_DEPRECATED Ptr< Stitcher > createStitcherScans(bool try_use_gpu=false)
cv
"black box" representation of the file storage associated with a file on disk.
Definition: aruco.hpp:75
Definition: cvstd_wrapper.hpp:74