From 3bb685a744cb0748e89eeb9559be3b979de305b3 Mon Sep 17 00:00:00 2001 From: Alexey Spizhevoy Date: Mon, 23 May 2011 14:28:53 +0000 Subject: [PATCH] minor changes in opencv_stitching --- modules/stitching/blenders.cpp | 29 ++++++++++++++++++----------- modules/stitching/main.cpp | 2 +- 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/modules/stitching/blenders.cpp b/modules/stitching/blenders.cpp index 8a36bb5f96..9d6fc46a1b 100644 --- a/modules/stitching/blenders.cpp +++ b/modules/stitching/blenders.cpp @@ -185,13 +185,16 @@ void MultiBandBlender::feed(const Mat &img, const Mat &mask, Point tl) CV_Assert(img.type() == CV_16SC3); CV_Assert(mask.type() == CV_8U); - int top = tl.y - dst_roi_.y; - int left = tl.x - dst_roi_.x; - int bottom = dst_roi_.br().y - tl.y - img.rows; - int right = dst_roi_.br().x - tl.x - img.cols; + Point tl_new(dst_roi_.tl()); + Point br_new(dst_roi_.br()); + int top = tl.y - tl_new.y; + int left = tl.x - tl_new.x; + int bottom = br_new.y - tl.y - img.rows; + int right = br_new.x - tl.x - img.cols; // Create the source image Laplacian pyramid vector src_pyr_gauss(num_bands_ + 1); + src_pyr_gauss[0] = img; copyMakeBorder(img, src_pyr_gauss[0], top, bottom, left, right, BORDER_REFLECT); for (int i = 0; i < num_bands_; ++i) @@ -212,21 +215,25 @@ void MultiBandBlender::feed(const Mat &img, const Mat &mask, Point tl) // Add weighted layer of the source image to the final Laplacian pyramid layer for (int i = 0; i <= num_bands_; ++i) { - for (int y = 0; y < dst_pyr_laplace_[i].rows; ++y) + int dx = 0;//(tl_new.x >> i) - (dst_roi_.x >> i); + int dy = 0;//(tl_new.y >> i) - (dst_roi_.y >> i); + + for (int y = 0; y < src_pyr_laplace[i].rows; ++y) { const Point3_* src_row = src_pyr_laplace[i].ptr >(y); - Point3_* dst_row = dst_pyr_laplace_[i].ptr >(y); + Point3_* dst_row = dst_pyr_laplace_[i].ptr >(y + dy); const float* weight_row = weight_pyr_gauss[i].ptr(y); + float* dst_weight_row = dst_band_weights_[i].ptr(y + dy); - for (int x = 0; x < dst_pyr_laplace_[i].cols; ++x) + for (int x = 0; x < src_pyr_laplace[i].cols; ++x) { - dst_row[x].x += static_cast(src_row[x].x * weight_row[x]); - dst_row[x].y += static_cast(src_row[x].y * weight_row[x]); - dst_row[x].z += static_cast(src_row[x].z * weight_row[x]); + dst_row[x + dx].x += static_cast(src_row[x].x * weight_row[x]); + dst_row[x + dx].y += static_cast(src_row[x].y * weight_row[x]); + dst_row[x + dx].z += static_cast(src_row[x].z * weight_row[x]); + dst_weight_row[x + dx] += weight_row[x]; } } - dst_band_weights_[i] += weight_pyr_gauss[i]; } } diff --git a/modules/stitching/main.cpp b/modules/stitching/main.cpp index 2228725179..ff8f3e81e1 100644 --- a/modules/stitching/main.cpp +++ b/modules/stitching/main.cpp @@ -78,7 +78,7 @@ vector img_names; bool trygpu = false; double work_megapix = 0.3; double seam_megapix = 0.1; -double compose_megapix = 6; +double compose_megapix = 1; int ba_space = BundleAdjuster::FOCAL_RAY_SPACE; float conf_thresh = 1.f; bool wave_correct = true;