1
/*M///////////////////////////////////////////////////////////////////////////////////////
3
// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
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.
11
// For Open Source Computer Vision Library
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.
17
// Redistribution and use in source and binary forms, with or without modification,
18
// are permitted provided that the following conditions are met:
20
// * Redistribution's of source code must retain the above copyright notice,
21
// this list of conditions and the following disclaimer.
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.
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.
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.
43
#ifndef __OPENCV_STITCHING_BLENDERS_HPP__
44
#define __OPENCV_STITCHING_BLENDERS_HPP__
46
#include "opencv2/core.hpp"
51
//! @addtogroup stitching_blend
54
/** @brief Base class for all blenders.
56
Simple blender which puts one image over another
58
class CV_EXPORTS Blender
63
enum { NO, FEATHER, MULTI_BAND };
64
static Ptr<Blender> createDefault(int type, bool try_gpu = false);
66
/** @brief Prepares the blender for blending.
68
@param corners Source images top-left corners
69
@param sizes Source image sizes
71
void prepare(const std::vector<Point> &corners, const std::vector<Size> &sizes);
73
virtual void prepare(Rect dst_roi);
74
/** @brief Processes the image.
76
@param img Source image
77
@param mask Source image mask
78
@param tl Source image top-left corners
80
virtual void feed(InputArray img, InputArray mask, Point tl);
81
/** @brief Blends and returns the final pano.
84
@param dst_mask Final pano mask
86
virtual void blend(InputOutputArray dst, InputOutputArray dst_mask);
93
/** @brief Simple blender which mixes images at its borders.
95
class CV_EXPORTS FeatherBlender : public Blender
98
FeatherBlender(float sharpness = 0.02f);
100
float sharpness() const { return sharpness_; }
101
void setSharpness(float val) { sharpness_ = val; }
103
void prepare(Rect dst_roi);
104
void feed(InputArray img, InputArray mask, Point tl);
105
void blend(InputOutputArray dst, InputOutputArray dst_mask);
107
//! Creates weight maps for fixed set of source images by their masks and top-left corners.
108
//! Final image can be obtained by simple weighting of the source images.
109
Rect createWeightMaps(const std::vector<UMat> &masks, const std::vector<Point> &corners,
110
std::vector<UMat> &weight_maps);
115
UMat dst_weight_map_;
118
inline FeatherBlender::FeatherBlender(float _sharpness) { setSharpness(_sharpness); }
120
/** @brief Blender which uses multi-band blending algorithm (see @cite BA83).
122
class CV_EXPORTS MultiBandBlender : public Blender
125
MultiBandBlender(int try_gpu = false, int num_bands = 5, int weight_type = CV_32F);
127
int numBands() const { return actual_num_bands_; }
128
void setNumBands(int val) { actual_num_bands_ = val; }
130
void prepare(Rect dst_roi);
131
void feed(InputArray img, InputArray mask, Point tl);
132
void blend(InputOutputArray dst, InputOutputArray dst_mask);
135
int actual_num_bands_, num_bands_;
136
std::vector<UMat> dst_pyr_laplace_;
137
std::vector<UMat> dst_band_weights_;
140
int weight_type_; //CV_32F or CV_16S
144
//////////////////////////////////////////////////////////////////////////////
145
// Auxiliary functions
147
void CV_EXPORTS normalizeUsingWeightMap(InputArray weight, InputOutputArray src);
149
void CV_EXPORTS createWeightMap(InputArray mask, float sharpness, InputOutputArray weight);
151
void CV_EXPORTS createLaplacePyr(InputArray img, int num_levels, std::vector<UMat>& pyr);
152
void CV_EXPORTS createLaplacePyrGpu(InputArray img, int num_levels, std::vector<UMat>& pyr);
154
// Restores source image
155
void CV_EXPORTS restoreImageFromLaplacePyr(std::vector<UMat>& pyr);
156
void CV_EXPORTS restoreImageFromLaplacePyrGpu(std::vector<UMat>& pyr);
160
} // namespace detail
163
#endif // __OPENCV_STITCHING_BLENDERS_HPP__