43 #ifndef __OPENCV_STITCHING_SEAM_FINDERS_HPP__
44 #define __OPENCV_STITCHING_SEAM_FINDERS_HPP__
57 virtual void find(
const std::vector<Mat> &
src,
const std::vector<Point> &
corners,
58 std::vector<Mat> &masks) = 0;
65 void find(
const std::vector<Mat>&,
const std::vector<Point>&, std::vector<Mat>&) {}
72 virtual void find(
const std::vector<Mat> &
src,
const std::vector<Point> &
corners,
73 std::vector<Mat> &masks);
89 virtual void find(
const std::vector<Size> &
size,
const std::vector<Point> &
corners,
90 std::vector<Mat> &masks);
106 virtual void find(
const std::vector<Mat> &
src,
const std::vector<Point> &
corners,
107 std::vector<Mat> &masks);
112 FIRST = 1, SECOND = 2, INTERS = 4,
113 INTERS_FIRST = INTERS | FIRST,
114 INTERS_SECOND = INTERS | SECOND
120 ImagePairLess(
const std::vector<Mat> &images,
const std::vector<Point> &
corners)
121 : src_(&images[0]), corners_(&corners[0]) {}
123 bool operator() (
const std::pair<size_t, size_t> &l,
const std::pair<size_t, size_t> &
r)
const
125 Point c1 = corners_[l.first] +
Point(src_[l.first].cols / 2, src_[l.first].rows / 2);
126 Point c2 = corners_[l.second] +
Point(src_[l.second].cols / 2, src_[l.second].rows / 2);
127 int d1 = (c1 - c2).
dot(c1 - c2);
129 c1 = corners_[r.first] +
Point(src_[r.first].cols / 2, src_[r.first].rows / 2);
130 c2 = corners_[r.second] +
Point(src_[r.second].cols / 2, src_[r.second].rows / 2);
131 int d2 = (c1 - c2).
dot(c1 - c2);
138 const Point *corners_;
144 ClosePoints(
int minDist) : minDist_(minDist) {}
146 bool operator() (
const Point &p1,
const Point &
p2)
const
148 int dist2 = (p1.x-p2.x) * (p1.x-p2.x) + (p1.y-p2.y) * (p1.y-p2.y);
149 return dist2 < minDist_ * minDist_;
157 const Mat &image1,
const Mat &
image2,
Point tl1,
Point tl2, Mat &mask1, Mat &mask2);
159 void findComponents();
163 void resolveConflicts(
164 const Mat &image1,
const Mat &
image2,
Point tl1,
Point tl2, Mat &mask1, Mat &mask2);
166 void computeGradients(
const Mat &image1,
const Mat &
image2);
168 bool hasOnlyOneNeighbor(
int comp);
170 bool closeToContour(
int y,
int x,
const Mat_<uchar> &contourMask);
172 bool getSeamTips(
int comp1,
int comp2,
Point &p1,
Point &p2);
176 int comp, Mat_<float> &costV, Mat_<float> &costH);
180 Point p1,
Point p2, std::vector<Point> &seam,
bool &isHorizontal);
182 void updateLabelsUsingSeam(
183 int comp1,
int comp2,
const std::vector<Point> &seam,
bool isHorizontalSeam);
185 CostFunction costFunc_;
188 Point unionTl_, unionBr_;
190 Mat_<uchar> mask1_, mask2_;
191 Mat_<uchar> contour1mask_, contour2mask_;
192 Mat_<float> gradx1_, grady1_;
193 Mat_<float> gradx2_, grady2_;
198 std::vector<ComponentState> states_;
199 std::vector<Point> tls_, brs_;
200 std::vector<std::vector<Point> > contours_;
201 std::set<std::pair<int, int> > edges_;
208 enum { COST_COLOR, COST_COLOR_GRAD };
216 float bad_region_penalty = 1000.
f);
220 void find(
const std::vector<Mat> &
src,
const std::vector<Point> &
corners,
221 std::vector<Mat> &masks);
234 float bad_region_penalty = 1000.
f)
235 : cost_type_(cost_type), terminal_cost_(terminal_cost),
236 bad_region_penalty_(bad_region_penalty) {}
238 void find(
const std::vector<cv::Mat> &
src,
const std::vector<cv::Point> &
corners,
239 std::vector<cv::Mat> &masks);
248 std::vector<Mat> dx_, dy_;
250 float terminal_cost_;
251 float bad_region_penalty_;
257 #endif // __OPENCV_STITCHING_SEAM_FINDERS_HPP__
GLdouble GLdouble GLdouble r
Point2i Point
Definition: core.hpp:893
GLenum GLint GLint y
Definition: core_c.h:613
CvPoint2D32f p2
Definition: legacy.hpp:578
IplImage CvRect * roi
Definition: legacy.hpp:234
GLdouble GLdouble GLdouble GLdouble top
void setCostFunction(CostFunction val)
Definition: seam_finders.hpp:104
Size2i Size
Definition: core.hpp:896
virtual ~SeamFinder()
Definition: seam_finders.hpp:56
GLuint src
Definition: core_c.h:1650
std::vector< Point > corners_
Definition: seam_finders.hpp:81
Definition: seam_finders.hpp:212
std::vector< Mat > images_
Definition: seam_finders.hpp:79
void find(const std::vector< Mat > &, const std::vector< Point > &, std::vector< Mat > &)
Definition: seam_finders.hpp:65
void process(const Mat_< T1 > &m1, Mat_< T2 > &m2, Op op)
Definition: mat.hpp:1084
Definition: seam_finders.hpp:205
Definition: seam_finders.hpp:69
IplImage CvMemStorage CvSeq ** comp
Definition: legacy.hpp:2917
Definition: seam_finders.hpp:53
GLint * first
Definition: legacy.hpp:1133
const CvArr * image2
Definition: imgproc_c.h:64
Definition: seam_finders.hpp:230
GLenum GLint x
Definition: core_c.h:632
CostFunction
Definition: seam_finders.hpp:99
The n-dimensional matrix class.
Definition: core.hpp:1688
Definition: seam_finders.hpp:96
CvSize CvPoint2D32f * corners
Definition: calib3d.hpp:215
GraphCutSeamFinderGpu(int cost_type=COST_COLOR_GRAD, float terminal_cost=10000.f, float bad_region_penalty=1000.f)
Definition: seam_finders.hpp:233
CostFunction costFunction() const
Definition: seam_finders.hpp:103
std::vector< Size > sizes_
Definition: seam_finders.hpp:80
Definition: seam_finders.hpp:86
int int int * second
Definition: legacy.hpp:1115
Smart pointer to dynamically allocated objects.
Definition: core.hpp:1268
GLdouble GLdouble GLdouble bottom
std::vector< Mat > masks_
Definition: seam_finders.hpp:82
Definition: seam_finders.hpp:62
DataType< _Tp >::work_type dot(const Vector< _Tp > &v1, const Vector< _Tp > &v2)
Definition: operations.hpp:2465
GLsizeiptr size
Definition: core_c.h:939