pull/7/merge
alexey.spizhevoy 12 years ago committed by Alexey Spizhevoy
parent 85d1c463b9
commit 7222f2724f
  1. 6
      modules/stitching/include/opencv2/stitching/detail/seam_finders.hpp
  2. 7
      modules/stitching/src/seam_finders.cpp

@ -103,6 +103,9 @@ public:
CostFunction costFunction() const { return costFunc_; } CostFunction costFunction() const { return costFunc_; }
void setCostFunction(CostFunction val) { costFunc_ = val; } void setCostFunction(CostFunction val) { costFunc_ = val; }
virtual void find(const std::vector<Mat> &src, const std::vector<Point> &corners,
std::vector<Mat> &masks);
private: private:
enum ComponentState enum ComponentState
{ {
@ -150,9 +153,6 @@ private:
int minDist_; int minDist_;
}; };
virtual void find(const std::vector<Mat> &src, const std::vector<Point> &corners,
std::vector<Mat> &masks);
void process(const Mat &image1, const Mat &image2, Point tl1, Point tl2, void process(const Mat &image1, const Mat &image2, Point tl1, Point tl2,
Mat &mask1, Mat &mask2); Mat &mask1, Mat &mask2);

@ -189,6 +189,9 @@ void DpSeamFinder::process(
const Mat &image1, const Mat &image2, Point tl1, Point tl2, const Mat &image1, const Mat &image2, Point tl1, Point tl2,
Mat &mask1, Mat &mask2) 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 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), 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) for (int x = 0; x < mask2.cols; ++x)
{ {
int l = labels_(y - dy2, x - dx2); int l = labels_(y - dy2, x - dx2);
if ((states_[l-1] & FIRST) && mask1.at<uchar>(y - dy2 + dy1, x - dx2 + dx1)) if (l > 0 && (states_[l-1] & FIRST) && mask1.at<uchar>(y - dy2 + dy1, x - dx2 + dx1))
mask2.at<uchar>(y, x) = 0; mask2.at<uchar>(y, x) = 0;
} }
} }
@ -499,7 +502,7 @@ void DpSeamFinder::resolveConflicts(const Mat &image1, const Mat &image2,
for (int x = 0; x < mask1.cols; ++x) for (int x = 0; x < mask1.cols; ++x)
{ {
int l = labels_(y - dy1, x - dx1); int l = labels_(y - dy1, x - dx1);
if ((states_[l-1] & SECOND) && mask2.at<uchar>(y - dy1 + dy2, x - dx1 + dx2)) if (l > 0 && (states_[l-1] & SECOND) && mask2.at<uchar>(y - dy1 + dy2, x - dx1 + dx2))
mask1.at<uchar>(y, x) = 0; mask1.at<uchar>(y, x) = 0;
} }
} }

Loading…
Cancel
Save