00001 /*M/////////////////////////////////////////////////////////////////////////////////////// 00002 // 00003 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. 00004 // 00005 // By downloading, copying, installing or using the software you agree to this license. 00006 // If you do not agree to this license, do not download, install, 00007 // copy or use the software. 00008 // 00009 // 00010 // License Agreement 00011 // For Open Source Computer Vision Library 00012 // 00013 // Copyright (C) 2000-2008, Intel Corporation, all rights reserved. 00014 // Copyright (C) 2009, Willow Garage Inc., all rights reserved. 00015 // Third party copyrights are property of their respective owners. 00016 // 00017 // Redistribution and use in source and binary forms, with or without modification, 00018 // are permitted provided that the following conditions are met: 00019 // 00020 // * Redistribution's of source code must retain the above copyright notice, 00021 // this list of conditions and the following disclaimer. 00022 // 00023 // * Redistribution's in binary form must reproduce the above copyright notice, 00024 // this list of conditions and the following disclaimer in the documentation 00025 // and/or other materials provided with the distribution. 00026 // 00027 // * The name of the copyright holders may not be used to endorse or promote products 00028 // derived from this software without specific prior written permission. 00029 // 00030 // This software is provided by the copyright holders and contributors "as is" and 00031 // any express or implied warranties, including, but not limited to, the implied 00032 // warranties of merchantability and fitness for a particular purpose are disclaimed. 00033 // In no event shall the Intel Corporation or contributors be liable for any direct, 00034 // indirect, incidental, special, exemplary, or consequential damages 00035 // (including, but not limited to, procurement of substitute goods or services; 00036 // loss of use, data, or profits; or business interruption) however caused 00037 // and on any theory of liability, whether in contract, strict liability, 00038 // or tort (including negligence or otherwise) arising in any way out of 00039 // the use of this software, even if advised of the possibility of such damage. 00040 // 00041 //M*/ 00042 00043 #ifndef __OPENCV_STITCHING_STITCHER_HPP__ 00044 #define __OPENCV_STITCHING_STITCHER_HPP__ 00045 00046 #include "opencv2/core/core.hpp" 00047 #include "opencv2/features2d/features2d.hpp" 00048 #include "opencv2/stitching/warpers.hpp" 00049 #include "opencv2/stitching/detail/matchers.hpp" 00050 #include "opencv2/stitching/detail/motion_estimators.hpp" 00051 #include "opencv2/stitching/detail/exposure_compensate.hpp" 00052 #include "opencv2/stitching/detail/seam_finders.hpp" 00053 #include "opencv2/stitching/detail/blenders.hpp" 00054 #include "opencv2/stitching/detail/camera.hpp" 00055 00056 namespace cv { 00057 00058 class CV_EXPORTS Stitcher 00059 { 00060 public: 00061 enum { ORIG_RESOL = -1 }; 00062 enum Status { OK, ERR_NEED_MORE_IMGS }; 00063 00064 // Creates stitcher with default parameters 00065 static Stitcher createDefault(bool try_use_gpu = false); 00066 00067 double registrationResol() const { return registr_resol_; } 00068 void setRegistrationResol(double resol_mpx) { registr_resol_ = resol_mpx; } 00069 00070 double seamEstimationResol() const { return seam_est_resol_; } 00071 void setSeamEstimationResol(double resol_mpx) { seam_est_resol_ = resol_mpx; } 00072 00073 double compositingResol() const { return compose_resol_; } 00074 void setCompositingResol(double resol_mpx) { compose_resol_ = resol_mpx; } 00075 00076 double panoConfidenceThresh() const { return conf_thresh_; } 00077 void setPanoConfidenceThresh(double conf_thresh) { conf_thresh_ = conf_thresh; } 00078 00079 bool waveCorrection() const { return do_wave_correct_; } 00080 void setWaveCorrection(bool flag) { do_wave_correct_ = flag; } 00081 00082 detail::WaveCorrectKind waveCorrectKind() const { return wave_correct_kind_; } 00083 void setWaveCorrectKind(detail::WaveCorrectKind kind) { wave_correct_kind_ = kind; } 00084 00085 Ptr<detail::FeaturesFinder> featuresFinder() { return features_finder_; } 00086 const Ptr<detail::FeaturesFinder> featuresFinder() const { return features_finder_; } 00087 void setFeaturesFinder(Ptr<detail::FeaturesFinder> features_finder) 00088 { features_finder_ = features_finder; } 00089 00090 Ptr<detail::FeaturesMatcher> featuresMatcher() { return features_matcher_; } 00091 const Ptr<detail::FeaturesMatcher> featuresMatcher() const { return features_matcher_; } 00092 void setFeaturesMatcher(Ptr<detail::FeaturesMatcher> features_matcher) 00093 { features_matcher_ = features_matcher; } 00094 00095 const cv::Mat& matchingMask() const { return matching_mask_; } 00096 void setMatchingMask(const cv::Mat &mask) 00097 { 00098 CV_Assert(mask.type() == CV_8U && mask.cols == mask.rows); 00099 matching_mask_ = mask.clone(); 00100 } 00101 00102 Ptr<detail::BundleAdjusterBase> bundleAdjuster() { return bundle_adjuster_; } 00103 const Ptr<detail::BundleAdjusterBase> bundleAdjuster() const { return bundle_adjuster_; } 00104 void setBundleAdjuster(Ptr<detail::BundleAdjusterBase> bundle_adjuster) 00105 { bundle_adjuster_ = bundle_adjuster; } 00106 00107 Ptr<WarperCreator> warper() { return warper_; } 00108 const Ptr<WarperCreator> warper() const { return warper_; } 00109 void setWarper(Ptr<WarperCreator> creator) { warper_ = creator; } 00110 00111 Ptr<detail::ExposureCompensator> exposureCompensator() { return exposure_comp_; } 00112 const Ptr<detail::ExposureCompensator> exposureCompensator() const { return exposure_comp_; } 00113 void setExposureCompensator(Ptr<detail::ExposureCompensator> exposure_comp) 00114 { exposure_comp_ = exposure_comp; } 00115 00116 Ptr<detail::SeamFinder> seamFinder() { return seam_finder_; } 00117 const Ptr<detail::SeamFinder> seamFinder() const { return seam_finder_; } 00118 void setSeamFinder(Ptr<detail::SeamFinder> seam_finder) { seam_finder_ = seam_finder; } 00119 00120 Ptr<detail::Blender> blender() { return blender_; } 00121 const Ptr<detail::Blender> blender() const { return blender_; } 00122 void setBlender(Ptr<detail::Blender> b) { blender_ = b; } 00123 00124 Status estimateTransform(InputArray images); 00125 Status estimateTransform(InputArray images, const std::vector<std::vector<Rect> > &rois); 00126 00127 Status composePanorama(OutputArray pano); 00128 Status composePanorama(InputArray images, OutputArray pano); 00129 00130 Status stitch(InputArray images, OutputArray pano); 00131 Status stitch(InputArray images, const std::vector<std::vector<Rect> > &rois, OutputArray pano); 00132 00133 std::vector<int> component() const { return indices_; } 00134 std::vector<detail::CameraParams> cameras() const { return cameras_; } 00135 double workScale() const { return work_scale_; } 00136 00137 private: 00138 Stitcher() {} 00139 00140 Status matchImages(); 00141 void estimateCameraParams(); 00142 00143 double registr_resol_; 00144 double seam_est_resol_; 00145 double compose_resol_; 00146 double conf_thresh_; 00147 Ptr<detail::FeaturesFinder> features_finder_; 00148 Ptr<detail::FeaturesMatcher> features_matcher_; 00149 cv::Mat matching_mask_; 00150 Ptr<detail::BundleAdjusterBase> bundle_adjuster_; 00151 bool do_wave_correct_; 00152 detail::WaveCorrectKind wave_correct_kind_; 00153 Ptr<WarperCreator> warper_; 00154 Ptr<detail::ExposureCompensator> exposure_comp_; 00155 Ptr<detail::SeamFinder> seam_finder_; 00156 Ptr<detail::Blender> blender_; 00157 00158 std::vector<cv::Mat> imgs_; 00159 std::vector<std::vector<cv::Rect> > rois_; 00160 std::vector<cv::Size> full_img_sizes_; 00161 std::vector<detail::ImageFeatures> features_; 00162 std::vector<detail::MatchesInfo> pairwise_matches_; 00163 std::vector<cv::Mat> seam_est_imgs_; 00164 std::vector<int> indices_; 00165 std::vector<detail::CameraParams> cameras_; 00166 double work_scale_; 00167 double seam_scale_; 00168 double seam_work_aspect_; 00169 double warped_image_scale_; 00170 }; 00171 00172 } // namespace cv 00173 00174 #endif // __OPENCV_STITCHING_STITCHER_HPP__