From 7222f2724fec2564d5127546ce25889520f98762 Mon Sep 17 00:00:00 2001 From: "alexey.spizhevoy" Date: Mon, 6 Aug 2012 14:57:45 +0400 Subject: [PATCH] Fixed bug --- .../include/opencv2/stitching/detail/seam_finders.hpp | 6 +++--- modules/stitching/src/seam_finders.cpp | 7 +++++-- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/modules/stitching/include/opencv2/stitching/detail/seam_finders.hpp b/modules/stitching/include/opencv2/stitching/detail/seam_finders.hpp index 7a19e4531..4e0c9352d 100644 --- a/modules/stitching/include/opencv2/stitching/detail/seam_finders.hpp +++ b/modules/stitching/include/opencv2/stitching/detail/seam_finders.hpp @@ -103,6 +103,9 @@ public: CostFunction costFunction() const { return costFunc_; } void setCostFunction(CostFunction val) { costFunc_ = val; } + virtual void find(const std::vector &src, const std::vector &corners, + std::vector &masks); + private: enum ComponentState { @@ -150,9 +153,6 @@ private: int minDist_; }; - virtual void find(const std::vector &src, const std::vector &corners, - std::vector &masks); - void process(const Mat &image1, const Mat &image2, Point tl1, Point tl2, Mat &mask1, Mat &mask2); diff --git a/modules/stitching/src/seam_finders.cpp b/modules/stitching/src/seam_finders.cpp index ad5edeeb0..f1c21dc13 100644 --- a/modules/stitching/src/seam_finders.cpp +++ b/modules/stitching/src/seam_finders.cpp @@ -189,6 +189,9 @@ void DpSeamFinder::process( const Mat &image1, const Mat &image2, Point tl1, Point tl2, Mat &mask1, Mat &mask2) { + CV_Assert(image1.size() == mask1.size()); + CV_Assert(image2.size() == mask2.size()); + Point intersectTl(std::max(tl1.x, tl2.x), std::max(tl1.y, tl2.y)); Point intersectBr(std::min(tl1.x + image1.cols, tl2.x + image2.cols), @@ -489,7 +492,7 @@ void DpSeamFinder::resolveConflicts(const Mat &image1, const Mat &image2, for (int x = 0; x < mask2.cols; ++x) { int l = labels_(y - dy2, x - dx2); - if ((states_[l-1] & FIRST) && mask1.at(y - dy2 + dy1, x - dx2 + dx1)) + if (l > 0 && (states_[l-1] & FIRST) && mask1.at(y - dy2 + dy1, x - dx2 + dx1)) mask2.at(y, x) = 0; } } @@ -499,7 +502,7 @@ void DpSeamFinder::resolveConflicts(const Mat &image1, const Mat &image2, for (int x = 0; x < mask1.cols; ++x) { int l = labels_(y - dy1, x - dx1); - if ((states_[l-1] & SECOND) && mask2.at(y - dy1 + dy2, x - dx1 + dx2)) + if (l > 0 && (states_[l-1] & SECOND) && mask2.at(y - dy1 + dy2, x - dx1 + dx2)) mask1.at(y, x) = 0; } }