stitcher.hpp
Go to the documentation of this file.
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/core.hpp"
55 
56 namespace cv {
57 
58 class CV_EXPORTS Stitcher
59 {
60 public:
61  enum { ORIG_RESOL = -1 };
62  enum Status { OK, ERR_NEED_MORE_IMGS };
63 
64  // Creates stitcher with default parameters
65  static Stitcher createDefault(bool try_use_gpu = false);
66 
67  double registrationResol() const { return registr_resol_; }
68  void setRegistrationResol(double resol_mpx) { registr_resol_ = resol_mpx; }
69 
70  double seamEstimationResol() const { return seam_est_resol_; }
71  void setSeamEstimationResol(double resol_mpx) { seam_est_resol_ = resol_mpx; }
72 
73  double compositingResol() const { return compose_resol_; }
74  void setCompositingResol(double resol_mpx) { compose_resol_ = resol_mpx; }
75 
76  double panoConfidenceThresh() const { return conf_thresh_; }
77  void setPanoConfidenceThresh(double conf_thresh) { conf_thresh_ = conf_thresh; }
78 
79  bool waveCorrection() const { return do_wave_correct_; }
80  void setWaveCorrection(bool flag) { do_wave_correct_ = flag; }
81 
82  detail::WaveCorrectKind waveCorrectKind() const { return wave_correct_kind_; }
83  void setWaveCorrectKind(detail::WaveCorrectKind kind) { wave_correct_kind_ = kind; }
84 
85  Ptr<detail::FeaturesFinder> featuresFinder() { return features_finder_; }
86  const Ptr<detail::FeaturesFinder> featuresFinder() const { return features_finder_; }
88  { features_finder_ = features_finder; }
89 
90  Ptr<detail::FeaturesMatcher> featuresMatcher() { return features_matcher_; }
91  const Ptr<detail::FeaturesMatcher> featuresMatcher() const { return features_matcher_; }
93  { features_matcher_ = features_matcher; }
94 
95  const cv::Mat& matchingMask() const { return matching_mask_; }
97  {
98  CV_Assert(mask.type() == CV_8U && mask.cols == mask.rows);
99  matching_mask_ = mask.clone();
100  }
101 
102  Ptr<detail::BundleAdjusterBase> bundleAdjuster() { return bundle_adjuster_; }
103  const Ptr<detail::BundleAdjusterBase> bundleAdjuster() const { return bundle_adjuster_; }
105  { bundle_adjuster_ = bundle_adjuster; }
106 
107  Ptr<WarperCreator> warper() { return warper_; }
108  const Ptr<WarperCreator> warper() const { return warper_; }
109  void setWarper(Ptr<WarperCreator> creator) { warper_ = creator; }
110 
112  const Ptr<detail::ExposureCompensator> exposureCompensator() const { return exposure_comp_; }
114  { exposure_comp_ = exposure_comp; }
115 
116  Ptr<detail::SeamFinder> seamFinder() { return seam_finder_; }
117  const Ptr<detail::SeamFinder> seamFinder() const { return seam_finder_; }
118  void setSeamFinder(Ptr<detail::SeamFinder> seam_finder) { seam_finder_ = seam_finder; }
119 
120  Ptr<detail::Blender> blender() { return blender_; }
121  const Ptr<detail::Blender> blender() const { return blender_; }
122  void setBlender(Ptr<detail::Blender> b) { blender_ = b; }
123 
124  Status estimateTransform(InputArray images);
125  Status estimateTransform(InputArray images, const std::vector<std::vector<Rect> > &rois);
126 
127  Status composePanorama(OutputArray pano);
128  Status composePanorama(InputArray images, OutputArray pano);
129 
130  Status stitch(InputArray images, OutputArray pano);
131  Status stitch(InputArray images, const std::vector<std::vector<Rect> > &rois, OutputArray pano);
132 
133  std::vector<int> component() const { return indices_; }
134  std::vector<detail::CameraParams> cameras() const { return cameras_; }
135  double workScale() const { return work_scale_; }
136 
137 private:
138  Stitcher() {}
139 
140  Status matchImages();
141  void estimateCameraParams();
142 
143  double registr_resol_;
144  double seam_est_resol_;
145  double compose_resol_;
146  double conf_thresh_;
147  Ptr<detail::FeaturesFinder> features_finder_;
148  Ptr<detail::FeaturesMatcher> features_matcher_;
149  cv::Mat matching_mask_;
150  Ptr<detail::BundleAdjusterBase> bundle_adjuster_;
151  bool do_wave_correct_;
152  detail::WaveCorrectKind wave_correct_kind_;
153  Ptr<WarperCreator> warper_;
154  Ptr<detail::ExposureCompensator> exposure_comp_;
155  Ptr<detail::SeamFinder> seam_finder_;
156  Ptr<detail::Blender> blender_;
157 
158  std::vector<cv::Mat> imgs_;
159  std::vector<std::vector<cv::Rect> > rois_;
160  std::vector<cv::Size> full_img_sizes_;
161  std::vector<detail::ImageFeatures> features_;
162  std::vector<detail::MatchesInfo> pairwise_matches_;
163  std::vector<cv::Mat> seam_est_imgs_;
164  std::vector<int> indices_;
165  std::vector<detail::CameraParams> cameras_;
166  double work_scale_;
167  double seam_scale_;
168  double seam_work_aspect_;
169  double warped_image_scale_;
170 };
171 
172 } // namespace cv
173 
174 #endif // __OPENCV_STITCHING_STITCHER_HPP__
int rows
the number of rows and columns or (-1, -1) when the matrix has more than 2 dimensions ...
Definition: core.hpp:1962
const cv::Mat & matchingMask() const
Definition: stitcher.hpp:95
void setWarper(Ptr< WarperCreator > creator)
Definition: stitcher.hpp:109
void setMatchingMask(const cv::Mat &mask)
Definition: stitcher.hpp:96
double compositingResol() const
Definition: stitcher.hpp:73
detail::WaveCorrectKind waveCorrectKind() const
Definition: stitcher.hpp:82
Ptr< detail::SeamFinder > seamFinder()
Definition: stitcher.hpp:116
Mat clone() const
returns deep copy of the matrix, i.e. the data is copied
Definition: mat.hpp:332
bool waveCorrection() const
Definition: stitcher.hpp:79
CvPoint2D32f float float b
Definition: legacy.hpp:578
void setSeamFinder(Ptr< detail::SeamFinder > seam_finder)
Definition: stitcher.hpp:118
typedef Status(APIENTRYP GLEEPFNGLXGETTRANSPARENTINDEXSUNPROC)(Display *dpy
const Ptr< detail::ExposureCompensator > exposureCompensator() const
Definition: stitcher.hpp:112
double registrationResol() const
Definition: stitcher.hpp:67
Proxy datatype for passing Mat's and vector<>'s as input parameters.
Definition: core.hpp:1312
void setCompositingResol(double resol_mpx)
Definition: stitcher.hpp:74
int cols
Definition: core.hpp:1962
double workScale() const
Definition: stitcher.hpp:135
Ptr< detail::ExposureCompensator > exposureCompensator()
Definition: stitcher.hpp:111
int type() const
returns element type, similar to CV_MAT_TYPE(cvmat->type)
Definition: mat.hpp:399
Ptr< WarperCreator > warper()
Definition: stitcher.hpp:107
void setSeamEstimationResol(double resol_mpx)
Definition: stitcher.hpp:71
void setFeaturesFinder(Ptr< detail::FeaturesFinder > features_finder)
Definition: stitcher.hpp:87
void setBlender(Ptr< detail::Blender > b)
Definition: stitcher.hpp:122
std::vector< detail::CameraParams > cameras() const
Definition: stitcher.hpp:134
void setExposureCompensator(Ptr< detail::ExposureCompensator > exposure_comp)
Definition: stitcher.hpp:113
void setFeaturesMatcher(Ptr< detail::FeaturesMatcher > features_matcher)
Definition: stitcher.hpp:92
double seamEstimationResol() const
Definition: stitcher.hpp:70
const Ptr< detail::Blender > blender() const
Definition: stitcher.hpp:121
double panoConfidenceThresh() const
Definition: stitcher.hpp:76
void setWaveCorrection(bool flag)
Definition: stitcher.hpp:80
int CvSeq float CvSize2D32f int flag
Definition: legacy.hpp:237
void setRegistrationResol(double resol_mpx)
Definition: stitcher.hpp:68
void setBundleAdjuster(Ptr< detail::BundleAdjusterBase > bundle_adjuster)
Definition: stitcher.hpp:104
The Core Functionality.
GLboolean GLboolean GLboolean b
Definition: legacy.hpp:633
Ptr< detail::BundleAdjusterBase > bundleAdjuster()
Definition: stitcher.hpp:102
The n-dimensional matrix class.
Definition: core.hpp:1688
void setPanoConfidenceThresh(double conf_thresh)
Definition: stitcher.hpp:77
const Ptr< detail::SeamFinder > seamFinder() const
Definition: stitcher.hpp:117
const Ptr< WarperCreator > warper() const
Definition: stitcher.hpp:108
std::vector< int > component() const
Definition: stitcher.hpp:133
Status
Definition: stitcher.hpp:62
void setWaveCorrectKind(detail::WaveCorrectKind kind)
Definition: stitcher.hpp:83
Ptr< detail::Blender > blender()
Definition: stitcher.hpp:120
Ptr< detail::FeaturesFinder > featuresFinder()
Definition: stitcher.hpp:85
const Ptr< detail::FeaturesFinder > featuresFinder() const
Definition: stitcher.hpp:86
Definition: stitcher.hpp:58
const Ptr< detail::BundleAdjusterBase > bundleAdjuster() const
Definition: stitcher.hpp:103
GLenum GLint GLuint mask
Definition: tracking.hpp:132
Ptr< detail::FeaturesMatcher > featuresMatcher()
Definition: stitcher.hpp:90
Proxy datatype for passing Mat's and vector<>'s as input parameters.
Definition: core.hpp:1400
WaveCorrectKind
Definition: motion_estimators.hpp:180
const Ptr< detail::FeaturesMatcher > featuresMatcher() const
Definition: stitcher.hpp:91