From 5b50d63754bade8ffa0109be75fb3300318561d0 Mon Sep 17 00:00:00 2001 From: Alexey Spizhevoy Date: Fri, 20 May 2011 07:44:37 +0000 Subject: [PATCH] added number of bands estimation in opencv_stitching --- modules/stitching/blenders.hpp | 3 +++ modules/stitching/main.cpp | 7 ++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/modules/stitching/blenders.hpp b/modules/stitching/blenders.hpp index ae1b6b3716..308a81f8c6 100644 --- a/modules/stitching/blenders.hpp +++ b/modules/stitching/blenders.hpp @@ -41,6 +41,9 @@ class MultiBandBlender : public Blender public: MultiBandBlender(int num_bands = 7) : num_bands_(num_bands) {} + int numBands() const { return num_bands_; } + void setNumBands(int val) { num_bands_ = val; } + private: cv::Point blend(const std::vector &src, const std::vector &corners, const std::vector &masks, cv::Mat& dst, cv::Mat& dst_mask); diff --git a/modules/stitching/main.cpp b/modules/stitching/main.cpp index 579cfdb2cc..996ce65121 100644 --- a/modules/stitching/main.cpp +++ b/modules/stitching/main.cpp @@ -347,8 +347,13 @@ int main(int argc, char* argv[]) t = getTickCount(); LOGLN("Blending images..."); - Mat result, result_mask; Ptr blender = Blender::createDefault(blend_type); + if (blend_type == Blender::MULTI_BAND) + // Ensure last pyramid layer area is about 1 pix + dynamic_cast((Blender*)(blender)) + ->setNumBands(static_cast(ceil(log(static_cast(images_f[0].size().area())) + / log(4.0)))); + Mat result, result_mask; (*blender)(images_f, corners, masks_warped, result, result_mask); LOGLN("Blending images, time: " << ((getTickCount() - t) / getTickFrequency()) << " sec");