openCV library for Renesas RZ/A
Dependents: RZ_A2M_Mbed_samples
include/opencv2/stitching/detail/seam_finders.hpp@0:0e0631af0305, 2021-01-29 (annotated)
- Committer:
- RyoheiHagimoto
- Date:
- Fri Jan 29 04:53:38 2021 +0000
- Revision:
- 0:0e0631af0305
copied from https://github.com/d-kato/opencv-lib.
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
RyoheiHagimoto | 0:0e0631af0305 | 1 | /*M/////////////////////////////////////////////////////////////////////////////////////// |
RyoheiHagimoto | 0:0e0631af0305 | 2 | // |
RyoheiHagimoto | 0:0e0631af0305 | 3 | // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING. |
RyoheiHagimoto | 0:0e0631af0305 | 4 | // |
RyoheiHagimoto | 0:0e0631af0305 | 5 | // By downloading, copying, installing or using the software you agree to this license. |
RyoheiHagimoto | 0:0e0631af0305 | 6 | // If you do not agree to this license, do not download, install, |
RyoheiHagimoto | 0:0e0631af0305 | 7 | // copy or use the software. |
RyoheiHagimoto | 0:0e0631af0305 | 8 | // |
RyoheiHagimoto | 0:0e0631af0305 | 9 | // |
RyoheiHagimoto | 0:0e0631af0305 | 10 | // License Agreement |
RyoheiHagimoto | 0:0e0631af0305 | 11 | // For Open Source Computer Vision Library |
RyoheiHagimoto | 0:0e0631af0305 | 12 | // |
RyoheiHagimoto | 0:0e0631af0305 | 13 | // Copyright (C) 2000-2008, Intel Corporation, all rights reserved. |
RyoheiHagimoto | 0:0e0631af0305 | 14 | // Copyright (C) 2009, Willow Garage Inc., all rights reserved. |
RyoheiHagimoto | 0:0e0631af0305 | 15 | // Third party copyrights are property of their respective owners. |
RyoheiHagimoto | 0:0e0631af0305 | 16 | // |
RyoheiHagimoto | 0:0e0631af0305 | 17 | // Redistribution and use in source and binary forms, with or without modification, |
RyoheiHagimoto | 0:0e0631af0305 | 18 | // are permitted provided that the following conditions are met: |
RyoheiHagimoto | 0:0e0631af0305 | 19 | // |
RyoheiHagimoto | 0:0e0631af0305 | 20 | // * Redistribution's of source code must retain the above copyright notice, |
RyoheiHagimoto | 0:0e0631af0305 | 21 | // this list of conditions and the following disclaimer. |
RyoheiHagimoto | 0:0e0631af0305 | 22 | // |
RyoheiHagimoto | 0:0e0631af0305 | 23 | // * Redistribution's in binary form must reproduce the above copyright notice, |
RyoheiHagimoto | 0:0e0631af0305 | 24 | // this list of conditions and the following disclaimer in the documentation |
RyoheiHagimoto | 0:0e0631af0305 | 25 | // and/or other materials provided with the distribution. |
RyoheiHagimoto | 0:0e0631af0305 | 26 | // |
RyoheiHagimoto | 0:0e0631af0305 | 27 | // * The name of the copyright holders may not be used to endorse or promote products |
RyoheiHagimoto | 0:0e0631af0305 | 28 | // derived from this software without specific prior written permission. |
RyoheiHagimoto | 0:0e0631af0305 | 29 | // |
RyoheiHagimoto | 0:0e0631af0305 | 30 | // This software is provided by the copyright holders and contributors "as is" and |
RyoheiHagimoto | 0:0e0631af0305 | 31 | // any express or implied warranties, including, but not limited to, the implied |
RyoheiHagimoto | 0:0e0631af0305 | 32 | // warranties of merchantability and fitness for a particular purpose are disclaimed. |
RyoheiHagimoto | 0:0e0631af0305 | 33 | // In no event shall the Intel Corporation or contributors be liable for any direct, |
RyoheiHagimoto | 0:0e0631af0305 | 34 | // indirect, incidental, special, exemplary, or consequential damages |
RyoheiHagimoto | 0:0e0631af0305 | 35 | // (including, but not limited to, procurement of substitute goods or services; |
RyoheiHagimoto | 0:0e0631af0305 | 36 | // loss of use, data, or profits; or business interruption) however caused |
RyoheiHagimoto | 0:0e0631af0305 | 37 | // and on any theory of liability, whether in contract, strict liability, |
RyoheiHagimoto | 0:0e0631af0305 | 38 | // or tort (including negligence or otherwise) arising in any way out of |
RyoheiHagimoto | 0:0e0631af0305 | 39 | // the use of this software, even if advised of the possibility of such damage. |
RyoheiHagimoto | 0:0e0631af0305 | 40 | // |
RyoheiHagimoto | 0:0e0631af0305 | 41 | //M*/ |
RyoheiHagimoto | 0:0e0631af0305 | 42 | |
RyoheiHagimoto | 0:0e0631af0305 | 43 | #ifndef OPENCV_STITCHING_SEAM_FINDERS_HPP |
RyoheiHagimoto | 0:0e0631af0305 | 44 | #define OPENCV_STITCHING_SEAM_FINDERS_HPP |
RyoheiHagimoto | 0:0e0631af0305 | 45 | |
RyoheiHagimoto | 0:0e0631af0305 | 46 | #include <set> |
RyoheiHagimoto | 0:0e0631af0305 | 47 | #include "opencv2/core.hpp" |
RyoheiHagimoto | 0:0e0631af0305 | 48 | #include "opencv2/opencv_modules.hpp" |
RyoheiHagimoto | 0:0e0631af0305 | 49 | |
RyoheiHagimoto | 0:0e0631af0305 | 50 | namespace cv { |
RyoheiHagimoto | 0:0e0631af0305 | 51 | namespace detail { |
RyoheiHagimoto | 0:0e0631af0305 | 52 | |
RyoheiHagimoto | 0:0e0631af0305 | 53 | //! @addtogroup stitching_seam |
RyoheiHagimoto | 0:0e0631af0305 | 54 | //! @{ |
RyoheiHagimoto | 0:0e0631af0305 | 55 | |
RyoheiHagimoto | 0:0e0631af0305 | 56 | /** @brief Base class for a seam estimator. |
RyoheiHagimoto | 0:0e0631af0305 | 57 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 58 | class CV_EXPORTS SeamFinder |
RyoheiHagimoto | 0:0e0631af0305 | 59 | { |
RyoheiHagimoto | 0:0e0631af0305 | 60 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 61 | virtual ~SeamFinder() {} |
RyoheiHagimoto | 0:0e0631af0305 | 62 | /** @brief Estimates seams. |
RyoheiHagimoto | 0:0e0631af0305 | 63 | |
RyoheiHagimoto | 0:0e0631af0305 | 64 | @param src Source images |
RyoheiHagimoto | 0:0e0631af0305 | 65 | @param corners Source image top-left corners |
RyoheiHagimoto | 0:0e0631af0305 | 66 | @param masks Source image masks to update |
RyoheiHagimoto | 0:0e0631af0305 | 67 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 68 | virtual void find(const std::vector<UMat> &src, const std::vector<Point> &corners, |
RyoheiHagimoto | 0:0e0631af0305 | 69 | std::vector<UMat> &masks) = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 70 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 71 | |
RyoheiHagimoto | 0:0e0631af0305 | 72 | /** @brief Stub seam estimator which does nothing. |
RyoheiHagimoto | 0:0e0631af0305 | 73 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 74 | class CV_EXPORTS NoSeamFinder : public SeamFinder |
RyoheiHagimoto | 0:0e0631af0305 | 75 | { |
RyoheiHagimoto | 0:0e0631af0305 | 76 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 77 | void find(const std::vector<UMat>&, const std::vector<Point>&, std::vector<UMat>&) {} |
RyoheiHagimoto | 0:0e0631af0305 | 78 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 79 | |
RyoheiHagimoto | 0:0e0631af0305 | 80 | /** @brief Base class for all pairwise seam estimators. |
RyoheiHagimoto | 0:0e0631af0305 | 81 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 82 | class CV_EXPORTS PairwiseSeamFinder : public SeamFinder |
RyoheiHagimoto | 0:0e0631af0305 | 83 | { |
RyoheiHagimoto | 0:0e0631af0305 | 84 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 85 | virtual void find(const std::vector<UMat> &src, const std::vector<Point> &corners, |
RyoheiHagimoto | 0:0e0631af0305 | 86 | std::vector<UMat> &masks); |
RyoheiHagimoto | 0:0e0631af0305 | 87 | |
RyoheiHagimoto | 0:0e0631af0305 | 88 | protected: |
RyoheiHagimoto | 0:0e0631af0305 | 89 | void run(); |
RyoheiHagimoto | 0:0e0631af0305 | 90 | /** @brief Resolves masks intersection of two specified images in the given ROI. |
RyoheiHagimoto | 0:0e0631af0305 | 91 | |
RyoheiHagimoto | 0:0e0631af0305 | 92 | @param first First image index |
RyoheiHagimoto | 0:0e0631af0305 | 93 | @param second Second image index |
RyoheiHagimoto | 0:0e0631af0305 | 94 | @param roi Region of interest |
RyoheiHagimoto | 0:0e0631af0305 | 95 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 96 | virtual void findInPair(size_t first, size_t second, Rect roi) = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 97 | |
RyoheiHagimoto | 0:0e0631af0305 | 98 | std::vector<UMat> images_; |
RyoheiHagimoto | 0:0e0631af0305 | 99 | std::vector<Size> sizes_; |
RyoheiHagimoto | 0:0e0631af0305 | 100 | std::vector<Point> corners_; |
RyoheiHagimoto | 0:0e0631af0305 | 101 | std::vector<UMat> masks_; |
RyoheiHagimoto | 0:0e0631af0305 | 102 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 103 | |
RyoheiHagimoto | 0:0e0631af0305 | 104 | /** @brief Voronoi diagram-based seam estimator. |
RyoheiHagimoto | 0:0e0631af0305 | 105 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 106 | class CV_EXPORTS VoronoiSeamFinder : public PairwiseSeamFinder |
RyoheiHagimoto | 0:0e0631af0305 | 107 | { |
RyoheiHagimoto | 0:0e0631af0305 | 108 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 109 | virtual void find(const std::vector<UMat> &src, const std::vector<Point> &corners, |
RyoheiHagimoto | 0:0e0631af0305 | 110 | std::vector<UMat> &masks); |
RyoheiHagimoto | 0:0e0631af0305 | 111 | virtual void find(const std::vector<Size> &size, const std::vector<Point> &corners, |
RyoheiHagimoto | 0:0e0631af0305 | 112 | std::vector<UMat> &masks); |
RyoheiHagimoto | 0:0e0631af0305 | 113 | private: |
RyoheiHagimoto | 0:0e0631af0305 | 114 | void findInPair(size_t first, size_t second, Rect roi); |
RyoheiHagimoto | 0:0e0631af0305 | 115 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 116 | |
RyoheiHagimoto | 0:0e0631af0305 | 117 | |
RyoheiHagimoto | 0:0e0631af0305 | 118 | class CV_EXPORTS DpSeamFinder : public SeamFinder |
RyoheiHagimoto | 0:0e0631af0305 | 119 | { |
RyoheiHagimoto | 0:0e0631af0305 | 120 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 121 | enum CostFunction { COLOR, COLOR_GRAD }; |
RyoheiHagimoto | 0:0e0631af0305 | 122 | |
RyoheiHagimoto | 0:0e0631af0305 | 123 | DpSeamFinder(CostFunction costFunc = COLOR); |
RyoheiHagimoto | 0:0e0631af0305 | 124 | |
RyoheiHagimoto | 0:0e0631af0305 | 125 | CostFunction costFunction() const { return costFunc_; } |
RyoheiHagimoto | 0:0e0631af0305 | 126 | void setCostFunction(CostFunction val) { costFunc_ = val; } |
RyoheiHagimoto | 0:0e0631af0305 | 127 | |
RyoheiHagimoto | 0:0e0631af0305 | 128 | virtual void find(const std::vector<UMat> &src, const std::vector<Point> &corners, |
RyoheiHagimoto | 0:0e0631af0305 | 129 | std::vector<UMat> &masks); |
RyoheiHagimoto | 0:0e0631af0305 | 130 | |
RyoheiHagimoto | 0:0e0631af0305 | 131 | private: |
RyoheiHagimoto | 0:0e0631af0305 | 132 | enum ComponentState |
RyoheiHagimoto | 0:0e0631af0305 | 133 | { |
RyoheiHagimoto | 0:0e0631af0305 | 134 | FIRST = 1, SECOND = 2, INTERS = 4, |
RyoheiHagimoto | 0:0e0631af0305 | 135 | INTERS_FIRST = INTERS | FIRST, |
RyoheiHagimoto | 0:0e0631af0305 | 136 | INTERS_SECOND = INTERS | SECOND |
RyoheiHagimoto | 0:0e0631af0305 | 137 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 138 | |
RyoheiHagimoto | 0:0e0631af0305 | 139 | class ImagePairLess |
RyoheiHagimoto | 0:0e0631af0305 | 140 | { |
RyoheiHagimoto | 0:0e0631af0305 | 141 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 142 | ImagePairLess(const std::vector<Mat> &images, const std::vector<Point> &corners) |
RyoheiHagimoto | 0:0e0631af0305 | 143 | : src_(&images[0]), corners_(&corners[0]) {} |
RyoheiHagimoto | 0:0e0631af0305 | 144 | |
RyoheiHagimoto | 0:0e0631af0305 | 145 | bool operator() (const std::pair<size_t, size_t> &l, const std::pair<size_t, size_t> &r) const |
RyoheiHagimoto | 0:0e0631af0305 | 146 | { |
RyoheiHagimoto | 0:0e0631af0305 | 147 | Point c1 = corners_[l.first] + Point(src_[l.first].cols / 2, src_[l.first].rows / 2); |
RyoheiHagimoto | 0:0e0631af0305 | 148 | Point c2 = corners_[l.second] + Point(src_[l.second].cols / 2, src_[l.second].rows / 2); |
RyoheiHagimoto | 0:0e0631af0305 | 149 | int d1 = (c1 - c2).dot(c1 - c2); |
RyoheiHagimoto | 0:0e0631af0305 | 150 | |
RyoheiHagimoto | 0:0e0631af0305 | 151 | c1 = corners_[r.first] + Point(src_[r.first].cols / 2, src_[r.first].rows / 2); |
RyoheiHagimoto | 0:0e0631af0305 | 152 | c2 = corners_[r.second] + Point(src_[r.second].cols / 2, src_[r.second].rows / 2); |
RyoheiHagimoto | 0:0e0631af0305 | 153 | int d2 = (c1 - c2).dot(c1 - c2); |
RyoheiHagimoto | 0:0e0631af0305 | 154 | |
RyoheiHagimoto | 0:0e0631af0305 | 155 | return d1 < d2; |
RyoheiHagimoto | 0:0e0631af0305 | 156 | } |
RyoheiHagimoto | 0:0e0631af0305 | 157 | |
RyoheiHagimoto | 0:0e0631af0305 | 158 | private: |
RyoheiHagimoto | 0:0e0631af0305 | 159 | const Mat *src_; |
RyoheiHagimoto | 0:0e0631af0305 | 160 | const Point *corners_; |
RyoheiHagimoto | 0:0e0631af0305 | 161 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 162 | |
RyoheiHagimoto | 0:0e0631af0305 | 163 | class ClosePoints |
RyoheiHagimoto | 0:0e0631af0305 | 164 | { |
RyoheiHagimoto | 0:0e0631af0305 | 165 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 166 | ClosePoints(int minDist) : minDist_(minDist) {} |
RyoheiHagimoto | 0:0e0631af0305 | 167 | |
RyoheiHagimoto | 0:0e0631af0305 | 168 | bool operator() (const Point &p1, const Point &p2) const |
RyoheiHagimoto | 0:0e0631af0305 | 169 | { |
RyoheiHagimoto | 0:0e0631af0305 | 170 | int dist2 = (p1.x-p2.x) * (p1.x-p2.x) + (p1.y-p2.y) * (p1.y-p2.y); |
RyoheiHagimoto | 0:0e0631af0305 | 171 | return dist2 < minDist_ * minDist_; |
RyoheiHagimoto | 0:0e0631af0305 | 172 | } |
RyoheiHagimoto | 0:0e0631af0305 | 173 | |
RyoheiHagimoto | 0:0e0631af0305 | 174 | private: |
RyoheiHagimoto | 0:0e0631af0305 | 175 | int minDist_; |
RyoheiHagimoto | 0:0e0631af0305 | 176 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 177 | |
RyoheiHagimoto | 0:0e0631af0305 | 178 | void process( |
RyoheiHagimoto | 0:0e0631af0305 | 179 | const Mat &image1, const Mat &image2, Point tl1, Point tl2, Mat &mask1, Mat &mask2); |
RyoheiHagimoto | 0:0e0631af0305 | 180 | |
RyoheiHagimoto | 0:0e0631af0305 | 181 | void findComponents(); |
RyoheiHagimoto | 0:0e0631af0305 | 182 | |
RyoheiHagimoto | 0:0e0631af0305 | 183 | void findEdges(); |
RyoheiHagimoto | 0:0e0631af0305 | 184 | |
RyoheiHagimoto | 0:0e0631af0305 | 185 | void resolveConflicts( |
RyoheiHagimoto | 0:0e0631af0305 | 186 | const Mat &image1, const Mat &image2, Point tl1, Point tl2, Mat &mask1, Mat &mask2); |
RyoheiHagimoto | 0:0e0631af0305 | 187 | |
RyoheiHagimoto | 0:0e0631af0305 | 188 | void computeGradients(const Mat &image1, const Mat &image2); |
RyoheiHagimoto | 0:0e0631af0305 | 189 | |
RyoheiHagimoto | 0:0e0631af0305 | 190 | bool hasOnlyOneNeighbor(int comp); |
RyoheiHagimoto | 0:0e0631af0305 | 191 | |
RyoheiHagimoto | 0:0e0631af0305 | 192 | bool closeToContour(int y, int x, const Mat_<uchar> &contourMask); |
RyoheiHagimoto | 0:0e0631af0305 | 193 | |
RyoheiHagimoto | 0:0e0631af0305 | 194 | bool getSeamTips(int comp1, int comp2, Point &p1, Point &p2); |
RyoheiHagimoto | 0:0e0631af0305 | 195 | |
RyoheiHagimoto | 0:0e0631af0305 | 196 | void computeCosts( |
RyoheiHagimoto | 0:0e0631af0305 | 197 | const Mat &image1, const Mat &image2, Point tl1, Point tl2, |
RyoheiHagimoto | 0:0e0631af0305 | 198 | int comp, Mat_<float> &costV, Mat_<float> &costH); |
RyoheiHagimoto | 0:0e0631af0305 | 199 | |
RyoheiHagimoto | 0:0e0631af0305 | 200 | bool estimateSeam( |
RyoheiHagimoto | 0:0e0631af0305 | 201 | const Mat &image1, const Mat &image2, Point tl1, Point tl2, int comp, |
RyoheiHagimoto | 0:0e0631af0305 | 202 | Point p1, Point p2, std::vector<Point> &seam, bool &isHorizontal); |
RyoheiHagimoto | 0:0e0631af0305 | 203 | |
RyoheiHagimoto | 0:0e0631af0305 | 204 | void updateLabelsUsingSeam( |
RyoheiHagimoto | 0:0e0631af0305 | 205 | int comp1, int comp2, const std::vector<Point> &seam, bool isHorizontalSeam); |
RyoheiHagimoto | 0:0e0631af0305 | 206 | |
RyoheiHagimoto | 0:0e0631af0305 | 207 | CostFunction costFunc_; |
RyoheiHagimoto | 0:0e0631af0305 | 208 | |
RyoheiHagimoto | 0:0e0631af0305 | 209 | // processing images pair data |
RyoheiHagimoto | 0:0e0631af0305 | 210 | Point unionTl_, unionBr_; |
RyoheiHagimoto | 0:0e0631af0305 | 211 | Size unionSize_; |
RyoheiHagimoto | 0:0e0631af0305 | 212 | Mat_<uchar> mask1_, mask2_; |
RyoheiHagimoto | 0:0e0631af0305 | 213 | Mat_<uchar> contour1mask_, contour2mask_; |
RyoheiHagimoto | 0:0e0631af0305 | 214 | Mat_<float> gradx1_, grady1_; |
RyoheiHagimoto | 0:0e0631af0305 | 215 | Mat_<float> gradx2_, grady2_; |
RyoheiHagimoto | 0:0e0631af0305 | 216 | |
RyoheiHagimoto | 0:0e0631af0305 | 217 | // components data |
RyoheiHagimoto | 0:0e0631af0305 | 218 | int ncomps_; |
RyoheiHagimoto | 0:0e0631af0305 | 219 | Mat_<int> labels_; |
RyoheiHagimoto | 0:0e0631af0305 | 220 | std::vector<ComponentState> states_; |
RyoheiHagimoto | 0:0e0631af0305 | 221 | std::vector<Point> tls_, brs_; |
RyoheiHagimoto | 0:0e0631af0305 | 222 | std::vector<std::vector<Point> > contours_; |
RyoheiHagimoto | 0:0e0631af0305 | 223 | std::set<std::pair<int, int> > edges_; |
RyoheiHagimoto | 0:0e0631af0305 | 224 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 225 | |
RyoheiHagimoto | 0:0e0631af0305 | 226 | /** @brief Base class for all minimum graph-cut-based seam estimators. |
RyoheiHagimoto | 0:0e0631af0305 | 227 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 228 | class CV_EXPORTS GraphCutSeamFinderBase |
RyoheiHagimoto | 0:0e0631af0305 | 229 | { |
RyoheiHagimoto | 0:0e0631af0305 | 230 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 231 | enum CostType { COST_COLOR, COST_COLOR_GRAD }; |
RyoheiHagimoto | 0:0e0631af0305 | 232 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 233 | |
RyoheiHagimoto | 0:0e0631af0305 | 234 | /** @brief Minimum graph cut-based seam estimator. See details in @cite V03 . |
RyoheiHagimoto | 0:0e0631af0305 | 235 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 236 | class CV_EXPORTS GraphCutSeamFinder : public GraphCutSeamFinderBase, public SeamFinder |
RyoheiHagimoto | 0:0e0631af0305 | 237 | { |
RyoheiHagimoto | 0:0e0631af0305 | 238 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 239 | GraphCutSeamFinder(int cost_type = COST_COLOR_GRAD, float terminal_cost = 10000.f, |
RyoheiHagimoto | 0:0e0631af0305 | 240 | float bad_region_penalty = 1000.f); |
RyoheiHagimoto | 0:0e0631af0305 | 241 | |
RyoheiHagimoto | 0:0e0631af0305 | 242 | ~GraphCutSeamFinder(); |
RyoheiHagimoto | 0:0e0631af0305 | 243 | |
RyoheiHagimoto | 0:0e0631af0305 | 244 | void find(const std::vector<UMat> &src, const std::vector<Point> &corners, |
RyoheiHagimoto | 0:0e0631af0305 | 245 | std::vector<UMat> &masks); |
RyoheiHagimoto | 0:0e0631af0305 | 246 | |
RyoheiHagimoto | 0:0e0631af0305 | 247 | private: |
RyoheiHagimoto | 0:0e0631af0305 | 248 | // To avoid GCGraph dependency |
RyoheiHagimoto | 0:0e0631af0305 | 249 | class Impl; |
RyoheiHagimoto | 0:0e0631af0305 | 250 | Ptr<PairwiseSeamFinder> impl_; |
RyoheiHagimoto | 0:0e0631af0305 | 251 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 252 | |
RyoheiHagimoto | 0:0e0631af0305 | 253 | |
RyoheiHagimoto | 0:0e0631af0305 | 254 | #ifdef HAVE_OPENCV_CUDALEGACY |
RyoheiHagimoto | 0:0e0631af0305 | 255 | class CV_EXPORTS GraphCutSeamFinderGpu : public GraphCutSeamFinderBase, public PairwiseSeamFinder |
RyoheiHagimoto | 0:0e0631af0305 | 256 | { |
RyoheiHagimoto | 0:0e0631af0305 | 257 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 258 | GraphCutSeamFinderGpu(int cost_type = COST_COLOR_GRAD, float terminal_cost = 10000.f, |
RyoheiHagimoto | 0:0e0631af0305 | 259 | float bad_region_penalty = 1000.f) |
RyoheiHagimoto | 0:0e0631af0305 | 260 | : cost_type_(cost_type), terminal_cost_(terminal_cost), |
RyoheiHagimoto | 0:0e0631af0305 | 261 | bad_region_penalty_(bad_region_penalty) {} |
RyoheiHagimoto | 0:0e0631af0305 | 262 | |
RyoheiHagimoto | 0:0e0631af0305 | 263 | void find(const std::vector<cv::UMat> &src, const std::vector<cv::Point> &corners, |
RyoheiHagimoto | 0:0e0631af0305 | 264 | std::vector<cv::UMat> &masks); |
RyoheiHagimoto | 0:0e0631af0305 | 265 | void findInPair(size_t first, size_t second, Rect roi); |
RyoheiHagimoto | 0:0e0631af0305 | 266 | |
RyoheiHagimoto | 0:0e0631af0305 | 267 | private: |
RyoheiHagimoto | 0:0e0631af0305 | 268 | void setGraphWeightsColor(const cv::Mat &img1, const cv::Mat &img2, const cv::Mat &mask1, const cv::Mat &mask2, |
RyoheiHagimoto | 0:0e0631af0305 | 269 | cv::Mat &terminals, cv::Mat &leftT, cv::Mat &rightT, cv::Mat &top, cv::Mat &bottom); |
RyoheiHagimoto | 0:0e0631af0305 | 270 | void setGraphWeightsColorGrad(const cv::Mat &img1, const cv::Mat &img2, const cv::Mat &dx1, const cv::Mat &dx2, |
RyoheiHagimoto | 0:0e0631af0305 | 271 | const cv::Mat &dy1, const cv::Mat &dy2, const cv::Mat &mask1, const cv::Mat &mask2, |
RyoheiHagimoto | 0:0e0631af0305 | 272 | cv::Mat &terminals, cv::Mat &leftT, cv::Mat &rightT, cv::Mat &top, cv::Mat &bottom); |
RyoheiHagimoto | 0:0e0631af0305 | 273 | std::vector<Mat> dx_, dy_; |
RyoheiHagimoto | 0:0e0631af0305 | 274 | int cost_type_; |
RyoheiHagimoto | 0:0e0631af0305 | 275 | float terminal_cost_; |
RyoheiHagimoto | 0:0e0631af0305 | 276 | float bad_region_penalty_; |
RyoheiHagimoto | 0:0e0631af0305 | 277 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 278 | #endif |
RyoheiHagimoto | 0:0e0631af0305 | 279 | |
RyoheiHagimoto | 0:0e0631af0305 | 280 | //! @} |
RyoheiHagimoto | 0:0e0631af0305 | 281 | |
RyoheiHagimoto | 0:0e0631af0305 | 282 | } // namespace detail |
RyoheiHagimoto | 0:0e0631af0305 | 283 | } // namespace cv |
RyoheiHagimoto | 0:0e0631af0305 | 284 | |
RyoheiHagimoto | 0:0e0631af0305 | 285 | #endif // OPENCV_STITCHING_SEAM_FINDERS_HPP |