Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 #ifndef __OPENCV_STITCHING_BLENDERS_HPP__
00044 #define __OPENCV_STITCHING_BLENDERS_HPP__
00045
00046 #include "opencv2/core/core.hpp"
00047
00048 namespace cv {
00049 namespace detail {
00050
00051
00052
00053 class CV_EXPORTS Blender
00054 {
00055 public:
00056 virtual ~Blender() {}
00057
00058 enum { NO, FEATHER, MULTI_BAND };
00059 static Ptr<Blender> createDefault(int type, bool try_gpu = false);
00060
00061 void prepare(const std::vector<Point> &corners, const std::vector<Size> &sizes);
00062 virtual void prepare(Rect dst_roi);
00063 virtual void feed(const Mat &img, const Mat &mask, Point tl);
00064 virtual void blend(Mat &dst, Mat &dst_mask);
00065
00066 protected:
00067 Mat dst_, dst_mask_;
00068 Rect dst_roi_;
00069 };
00070
00071
00072 class CV_EXPORTS FeatherBlender : public Blender
00073 {
00074 public:
00075 FeatherBlender(float sharpness = 0.02f);
00076
00077 float sharpness() const { return sharpness_; }
00078 void setSharpness(float val) { sharpness_ = val; }
00079
00080 void prepare(Rect dst_roi);
00081 void feed(const Mat &img, const Mat &mask, Point tl);
00082 void blend(Mat &dst, Mat &dst_mask);
00083
00084
00085
00086 Rect createWeightMaps(const std::vector<Mat> &masks, const std::vector<Point> &corners,
00087 std::vector<Mat> &weight_maps);
00088
00089 private:
00090 float sharpness_;
00091 Mat weight_map_;
00092 Mat dst_weight_map_;
00093 };
00094
00095 inline FeatherBlender::FeatherBlender(float _sharpness) { setSharpness(_sharpness); }
00096
00097
00098 class CV_EXPORTS MultiBandBlender : public Blender
00099 {
00100 public:
00101 MultiBandBlender(int try_gpu = false, int num_bands = 5, int weight_type = CV_32F);
00102
00103 int numBands() const { return actual_num_bands_; }
00104 void setNumBands(int val) { actual_num_bands_ = val; }
00105
00106 void prepare(Rect dst_roi);
00107 void feed(const Mat &img, const Mat &mask, Point tl);
00108 void blend(Mat &dst, Mat &dst_mask);
00109
00110 private:
00111 int actual_num_bands_, num_bands_;
00112 std::vector<Mat> dst_pyr_laplace_;
00113 std::vector<Mat> dst_band_weights_;
00114 Rect dst_roi_final_;
00115 bool can_use_gpu_;
00116 int weight_type_;
00117 };
00118
00119
00121
00122
00123 void CV_EXPORTS normalizeUsingWeightMap(const Mat& weight, Mat& src);
00124
00125 void CV_EXPORTS createWeightMap(const Mat& mask, float sharpness, Mat& weight);
00126
00127 void CV_EXPORTS createLaplacePyr(const Mat &img, int num_levels, std::vector<Mat>& pyr);
00128 void CV_EXPORTS createLaplacePyrGpu(const Mat &img, int num_levels, std::vector<Mat>& pyr);
00129
00130
00131 void CV_EXPORTS restoreImageFromLaplacePyr(std::vector<Mat>& pyr);
00132 void CV_EXPORTS restoreImageFromLaplacePyrGpu(std::vector<Mat>& pyr);
00133
00134 }
00135 }
00136
00137 #endif // __OPENCV_STITCHING_BLENDERS_HPP__