openCV library for Renesas RZ/A
Dependents: RZ_A2M_Mbed_samples
include/opencv2/stitching/detail/matchers.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_MATCHERS_HPP |
RyoheiHagimoto | 0:0e0631af0305 | 44 | #define OPENCV_STITCHING_MATCHERS_HPP |
RyoheiHagimoto | 0:0e0631af0305 | 45 | |
RyoheiHagimoto | 0:0e0631af0305 | 46 | #include "opencv2/core.hpp" |
RyoheiHagimoto | 0:0e0631af0305 | 47 | #include "opencv2/features2d.hpp" |
RyoheiHagimoto | 0:0e0631af0305 | 48 | |
RyoheiHagimoto | 0:0e0631af0305 | 49 | #include "opencv2/opencv_modules.hpp" |
RyoheiHagimoto | 0:0e0631af0305 | 50 | |
RyoheiHagimoto | 0:0e0631af0305 | 51 | #ifdef HAVE_OPENCV_XFEATURES2D |
RyoheiHagimoto | 0:0e0631af0305 | 52 | # include "opencv2/xfeatures2d/cuda.hpp" |
RyoheiHagimoto | 0:0e0631af0305 | 53 | #endif |
RyoheiHagimoto | 0:0e0631af0305 | 54 | |
RyoheiHagimoto | 0:0e0631af0305 | 55 | namespace cv { |
RyoheiHagimoto | 0:0e0631af0305 | 56 | namespace detail { |
RyoheiHagimoto | 0:0e0631af0305 | 57 | |
RyoheiHagimoto | 0:0e0631af0305 | 58 | //! @addtogroup stitching_match |
RyoheiHagimoto | 0:0e0631af0305 | 59 | //! @{ |
RyoheiHagimoto | 0:0e0631af0305 | 60 | |
RyoheiHagimoto | 0:0e0631af0305 | 61 | /** @brief Structure containing image keypoints and descriptors. */ |
RyoheiHagimoto | 0:0e0631af0305 | 62 | struct CV_EXPORTS ImageFeatures |
RyoheiHagimoto | 0:0e0631af0305 | 63 | { |
RyoheiHagimoto | 0:0e0631af0305 | 64 | int img_idx; |
RyoheiHagimoto | 0:0e0631af0305 | 65 | Size img_size; |
RyoheiHagimoto | 0:0e0631af0305 | 66 | std::vector<KeyPoint> keypoints; |
RyoheiHagimoto | 0:0e0631af0305 | 67 | UMat descriptors; |
RyoheiHagimoto | 0:0e0631af0305 | 68 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 69 | |
RyoheiHagimoto | 0:0e0631af0305 | 70 | /** @brief Feature finders base class */ |
RyoheiHagimoto | 0:0e0631af0305 | 71 | class CV_EXPORTS FeaturesFinder |
RyoheiHagimoto | 0:0e0631af0305 | 72 | { |
RyoheiHagimoto | 0:0e0631af0305 | 73 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 74 | virtual ~FeaturesFinder() {} |
RyoheiHagimoto | 0:0e0631af0305 | 75 | /** @overload */ |
RyoheiHagimoto | 0:0e0631af0305 | 76 | void operator ()(InputArray image, ImageFeatures &features); |
RyoheiHagimoto | 0:0e0631af0305 | 77 | /** @brief Finds features in the given image. |
RyoheiHagimoto | 0:0e0631af0305 | 78 | |
RyoheiHagimoto | 0:0e0631af0305 | 79 | @param image Source image |
RyoheiHagimoto | 0:0e0631af0305 | 80 | @param features Found features |
RyoheiHagimoto | 0:0e0631af0305 | 81 | @param rois Regions of interest |
RyoheiHagimoto | 0:0e0631af0305 | 82 | |
RyoheiHagimoto | 0:0e0631af0305 | 83 | @sa detail::ImageFeatures, Rect_ |
RyoheiHagimoto | 0:0e0631af0305 | 84 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 85 | void operator ()(InputArray image, ImageFeatures &features, const std::vector<cv::Rect> &rois); |
RyoheiHagimoto | 0:0e0631af0305 | 86 | /** @brief Finds features in the given images in parallel. |
RyoheiHagimoto | 0:0e0631af0305 | 87 | |
RyoheiHagimoto | 0:0e0631af0305 | 88 | @param images Source images |
RyoheiHagimoto | 0:0e0631af0305 | 89 | @param features Found features for each image |
RyoheiHagimoto | 0:0e0631af0305 | 90 | @param rois Regions of interest for each image |
RyoheiHagimoto | 0:0e0631af0305 | 91 | |
RyoheiHagimoto | 0:0e0631af0305 | 92 | @sa detail::ImageFeatures, Rect_ |
RyoheiHagimoto | 0:0e0631af0305 | 93 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 94 | void operator ()(InputArrayOfArrays images, std::vector<ImageFeatures> &features, |
RyoheiHagimoto | 0:0e0631af0305 | 95 | const std::vector<std::vector<cv::Rect> > &rois); |
RyoheiHagimoto | 0:0e0631af0305 | 96 | /** @overload */ |
RyoheiHagimoto | 0:0e0631af0305 | 97 | void operator ()(InputArrayOfArrays images, std::vector<ImageFeatures> &features); |
RyoheiHagimoto | 0:0e0631af0305 | 98 | /** @brief Frees unused memory allocated before if there is any. */ |
RyoheiHagimoto | 0:0e0631af0305 | 99 | virtual void collectGarbage() {} |
RyoheiHagimoto | 0:0e0631af0305 | 100 | |
RyoheiHagimoto | 0:0e0631af0305 | 101 | /* TODO OpenCV ABI 4.x |
RyoheiHagimoto | 0:0e0631af0305 | 102 | reimplement this as public method similar to FeaturesMatcher and remove private function hack |
RyoheiHagimoto | 0:0e0631af0305 | 103 | @return True, if it's possible to use the same finder instance in parallel, false otherwise |
RyoheiHagimoto | 0:0e0631af0305 | 104 | bool isThreadSafe() const { return is_thread_safe_; } |
RyoheiHagimoto | 0:0e0631af0305 | 105 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 106 | |
RyoheiHagimoto | 0:0e0631af0305 | 107 | protected: |
RyoheiHagimoto | 0:0e0631af0305 | 108 | /** @brief This method must implement features finding logic in order to make the wrappers |
RyoheiHagimoto | 0:0e0631af0305 | 109 | detail::FeaturesFinder::operator()_ work. |
RyoheiHagimoto | 0:0e0631af0305 | 110 | |
RyoheiHagimoto | 0:0e0631af0305 | 111 | @param image Source image |
RyoheiHagimoto | 0:0e0631af0305 | 112 | @param features Found features |
RyoheiHagimoto | 0:0e0631af0305 | 113 | |
RyoheiHagimoto | 0:0e0631af0305 | 114 | @sa detail::ImageFeatures */ |
RyoheiHagimoto | 0:0e0631af0305 | 115 | virtual void find(InputArray image, ImageFeatures &features) = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 116 | /** @brief uses dynamic_cast to determine thread-safety |
RyoheiHagimoto | 0:0e0631af0305 | 117 | @return True, if it's possible to use the same finder instance in parallel, false otherwise |
RyoheiHagimoto | 0:0e0631af0305 | 118 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 119 | bool isThreadSafe() const; |
RyoheiHagimoto | 0:0e0631af0305 | 120 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 121 | |
RyoheiHagimoto | 0:0e0631af0305 | 122 | /** @brief SURF features finder. |
RyoheiHagimoto | 0:0e0631af0305 | 123 | |
RyoheiHagimoto | 0:0e0631af0305 | 124 | @sa detail::FeaturesFinder, SURF |
RyoheiHagimoto | 0:0e0631af0305 | 125 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 126 | class CV_EXPORTS SurfFeaturesFinder : public FeaturesFinder |
RyoheiHagimoto | 0:0e0631af0305 | 127 | { |
RyoheiHagimoto | 0:0e0631af0305 | 128 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 129 | SurfFeaturesFinder(double hess_thresh = 300., int num_octaves = 3, int num_layers = 4, |
RyoheiHagimoto | 0:0e0631af0305 | 130 | int num_octaves_descr = /*4*/3, int num_layers_descr = /*2*/4); |
RyoheiHagimoto | 0:0e0631af0305 | 131 | |
RyoheiHagimoto | 0:0e0631af0305 | 132 | private: |
RyoheiHagimoto | 0:0e0631af0305 | 133 | void find(InputArray image, ImageFeatures &features); |
RyoheiHagimoto | 0:0e0631af0305 | 134 | |
RyoheiHagimoto | 0:0e0631af0305 | 135 | Ptr<FeatureDetector> detector_; |
RyoheiHagimoto | 0:0e0631af0305 | 136 | Ptr<DescriptorExtractor> extractor_; |
RyoheiHagimoto | 0:0e0631af0305 | 137 | Ptr<Feature2D> surf; |
RyoheiHagimoto | 0:0e0631af0305 | 138 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 139 | |
RyoheiHagimoto | 0:0e0631af0305 | 140 | /** @brief ORB features finder. : |
RyoheiHagimoto | 0:0e0631af0305 | 141 | |
RyoheiHagimoto | 0:0e0631af0305 | 142 | @sa detail::FeaturesFinder, ORB |
RyoheiHagimoto | 0:0e0631af0305 | 143 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 144 | class CV_EXPORTS OrbFeaturesFinder : public FeaturesFinder |
RyoheiHagimoto | 0:0e0631af0305 | 145 | { |
RyoheiHagimoto | 0:0e0631af0305 | 146 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 147 | OrbFeaturesFinder(Size _grid_size = Size(3,1), int nfeatures=1500, float scaleFactor=1.3f, int nlevels=5); |
RyoheiHagimoto | 0:0e0631af0305 | 148 | |
RyoheiHagimoto | 0:0e0631af0305 | 149 | private: |
RyoheiHagimoto | 0:0e0631af0305 | 150 | void find(InputArray image, ImageFeatures &features); |
RyoheiHagimoto | 0:0e0631af0305 | 151 | |
RyoheiHagimoto | 0:0e0631af0305 | 152 | Ptr<ORB> orb; |
RyoheiHagimoto | 0:0e0631af0305 | 153 | Size grid_size; |
RyoheiHagimoto | 0:0e0631af0305 | 154 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 155 | |
RyoheiHagimoto | 0:0e0631af0305 | 156 | /** @brief AKAZE features finder. : |
RyoheiHagimoto | 0:0e0631af0305 | 157 | |
RyoheiHagimoto | 0:0e0631af0305 | 158 | @sa detail::FeaturesFinder, AKAZE |
RyoheiHagimoto | 0:0e0631af0305 | 159 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 160 | class CV_EXPORTS AKAZEFeaturesFinder : public detail::FeaturesFinder |
RyoheiHagimoto | 0:0e0631af0305 | 161 | { |
RyoheiHagimoto | 0:0e0631af0305 | 162 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 163 | AKAZEFeaturesFinder(int descriptor_type = AKAZE::DESCRIPTOR_MLDB, |
RyoheiHagimoto | 0:0e0631af0305 | 164 | int descriptor_size = 0, |
RyoheiHagimoto | 0:0e0631af0305 | 165 | int descriptor_channels = 3, |
RyoheiHagimoto | 0:0e0631af0305 | 166 | float threshold = 0.001f, |
RyoheiHagimoto | 0:0e0631af0305 | 167 | int nOctaves = 4, |
RyoheiHagimoto | 0:0e0631af0305 | 168 | int nOctaveLayers = 4, |
RyoheiHagimoto | 0:0e0631af0305 | 169 | int diffusivity = KAZE::DIFF_PM_G2); |
RyoheiHagimoto | 0:0e0631af0305 | 170 | |
RyoheiHagimoto | 0:0e0631af0305 | 171 | private: |
RyoheiHagimoto | 0:0e0631af0305 | 172 | void find(InputArray image, detail::ImageFeatures &features); |
RyoheiHagimoto | 0:0e0631af0305 | 173 | |
RyoheiHagimoto | 0:0e0631af0305 | 174 | Ptr<AKAZE> akaze; |
RyoheiHagimoto | 0:0e0631af0305 | 175 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 176 | |
RyoheiHagimoto | 0:0e0631af0305 | 177 | #ifdef HAVE_OPENCV_XFEATURES2D |
RyoheiHagimoto | 0:0e0631af0305 | 178 | class CV_EXPORTS SurfFeaturesFinderGpu : public FeaturesFinder |
RyoheiHagimoto | 0:0e0631af0305 | 179 | { |
RyoheiHagimoto | 0:0e0631af0305 | 180 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 181 | SurfFeaturesFinderGpu(double hess_thresh = 300., int num_octaves = 3, int num_layers = 4, |
RyoheiHagimoto | 0:0e0631af0305 | 182 | int num_octaves_descr = 4, int num_layers_descr = 2); |
RyoheiHagimoto | 0:0e0631af0305 | 183 | |
RyoheiHagimoto | 0:0e0631af0305 | 184 | void collectGarbage(); |
RyoheiHagimoto | 0:0e0631af0305 | 185 | |
RyoheiHagimoto | 0:0e0631af0305 | 186 | private: |
RyoheiHagimoto | 0:0e0631af0305 | 187 | void find(InputArray image, ImageFeatures &features); |
RyoheiHagimoto | 0:0e0631af0305 | 188 | |
RyoheiHagimoto | 0:0e0631af0305 | 189 | cuda::GpuMat image_; |
RyoheiHagimoto | 0:0e0631af0305 | 190 | cuda::GpuMat gray_image_; |
RyoheiHagimoto | 0:0e0631af0305 | 191 | cuda::SURF_CUDA surf_; |
RyoheiHagimoto | 0:0e0631af0305 | 192 | cuda::GpuMat keypoints_; |
RyoheiHagimoto | 0:0e0631af0305 | 193 | cuda::GpuMat descriptors_; |
RyoheiHagimoto | 0:0e0631af0305 | 194 | int num_octaves_, num_layers_; |
RyoheiHagimoto | 0:0e0631af0305 | 195 | int num_octaves_descr_, num_layers_descr_; |
RyoheiHagimoto | 0:0e0631af0305 | 196 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 197 | #endif |
RyoheiHagimoto | 0:0e0631af0305 | 198 | |
RyoheiHagimoto | 0:0e0631af0305 | 199 | /** @brief Structure containing information about matches between two images. |
RyoheiHagimoto | 0:0e0631af0305 | 200 | |
RyoheiHagimoto | 0:0e0631af0305 | 201 | It's assumed that there is a transformation between those images. Transformation may be |
RyoheiHagimoto | 0:0e0631af0305 | 202 | homography or affine transformation based on selected matcher. |
RyoheiHagimoto | 0:0e0631af0305 | 203 | |
RyoheiHagimoto | 0:0e0631af0305 | 204 | @sa detail::FeaturesMatcher |
RyoheiHagimoto | 0:0e0631af0305 | 205 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 206 | struct CV_EXPORTS MatchesInfo |
RyoheiHagimoto | 0:0e0631af0305 | 207 | { |
RyoheiHagimoto | 0:0e0631af0305 | 208 | MatchesInfo(); |
RyoheiHagimoto | 0:0e0631af0305 | 209 | MatchesInfo(const MatchesInfo &other); |
RyoheiHagimoto | 0:0e0631af0305 | 210 | const MatchesInfo& operator =(const MatchesInfo &other); |
RyoheiHagimoto | 0:0e0631af0305 | 211 | |
RyoheiHagimoto | 0:0e0631af0305 | 212 | int src_img_idx, dst_img_idx; //!< Images indices (optional) |
RyoheiHagimoto | 0:0e0631af0305 | 213 | std::vector<DMatch> matches; |
RyoheiHagimoto | 0:0e0631af0305 | 214 | std::vector<uchar> inliers_mask; //!< Geometrically consistent matches mask |
RyoheiHagimoto | 0:0e0631af0305 | 215 | int num_inliers; //!< Number of geometrically consistent matches |
RyoheiHagimoto | 0:0e0631af0305 | 216 | Mat H; //!< Estimated transformation |
RyoheiHagimoto | 0:0e0631af0305 | 217 | double confidence; //!< Confidence two images are from the same panorama |
RyoheiHagimoto | 0:0e0631af0305 | 218 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 219 | |
RyoheiHagimoto | 0:0e0631af0305 | 220 | /** @brief Feature matchers base class. */ |
RyoheiHagimoto | 0:0e0631af0305 | 221 | class CV_EXPORTS FeaturesMatcher |
RyoheiHagimoto | 0:0e0631af0305 | 222 | { |
RyoheiHagimoto | 0:0e0631af0305 | 223 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 224 | virtual ~FeaturesMatcher() {} |
RyoheiHagimoto | 0:0e0631af0305 | 225 | |
RyoheiHagimoto | 0:0e0631af0305 | 226 | /** @overload |
RyoheiHagimoto | 0:0e0631af0305 | 227 | @param features1 First image features |
RyoheiHagimoto | 0:0e0631af0305 | 228 | @param features2 Second image features |
RyoheiHagimoto | 0:0e0631af0305 | 229 | @param matches_info Found matches |
RyoheiHagimoto | 0:0e0631af0305 | 230 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 231 | void operator ()(const ImageFeatures &features1, const ImageFeatures &features2, |
RyoheiHagimoto | 0:0e0631af0305 | 232 | MatchesInfo& matches_info) { match(features1, features2, matches_info); } |
RyoheiHagimoto | 0:0e0631af0305 | 233 | |
RyoheiHagimoto | 0:0e0631af0305 | 234 | /** @brief Performs images matching. |
RyoheiHagimoto | 0:0e0631af0305 | 235 | |
RyoheiHagimoto | 0:0e0631af0305 | 236 | @param features Features of the source images |
RyoheiHagimoto | 0:0e0631af0305 | 237 | @param pairwise_matches Found pairwise matches |
RyoheiHagimoto | 0:0e0631af0305 | 238 | @param mask Mask indicating which image pairs must be matched |
RyoheiHagimoto | 0:0e0631af0305 | 239 | |
RyoheiHagimoto | 0:0e0631af0305 | 240 | The function is parallelized with the TBB library. |
RyoheiHagimoto | 0:0e0631af0305 | 241 | |
RyoheiHagimoto | 0:0e0631af0305 | 242 | @sa detail::MatchesInfo |
RyoheiHagimoto | 0:0e0631af0305 | 243 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 244 | void operator ()(const std::vector<ImageFeatures> &features, std::vector<MatchesInfo> &pairwise_matches, |
RyoheiHagimoto | 0:0e0631af0305 | 245 | const cv::UMat &mask = cv::UMat()); |
RyoheiHagimoto | 0:0e0631af0305 | 246 | |
RyoheiHagimoto | 0:0e0631af0305 | 247 | /** @return True, if it's possible to use the same matcher instance in parallel, false otherwise |
RyoheiHagimoto | 0:0e0631af0305 | 248 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 249 | bool isThreadSafe() const { return is_thread_safe_; } |
RyoheiHagimoto | 0:0e0631af0305 | 250 | |
RyoheiHagimoto | 0:0e0631af0305 | 251 | /** @brief Frees unused memory allocated before if there is any. |
RyoheiHagimoto | 0:0e0631af0305 | 252 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 253 | virtual void collectGarbage() {} |
RyoheiHagimoto | 0:0e0631af0305 | 254 | |
RyoheiHagimoto | 0:0e0631af0305 | 255 | protected: |
RyoheiHagimoto | 0:0e0631af0305 | 256 | FeaturesMatcher(bool is_thread_safe = false) : is_thread_safe_(is_thread_safe) {} |
RyoheiHagimoto | 0:0e0631af0305 | 257 | |
RyoheiHagimoto | 0:0e0631af0305 | 258 | /** @brief This method must implement matching logic in order to make the wrappers |
RyoheiHagimoto | 0:0e0631af0305 | 259 | detail::FeaturesMatcher::operator()_ work. |
RyoheiHagimoto | 0:0e0631af0305 | 260 | |
RyoheiHagimoto | 0:0e0631af0305 | 261 | @param features1 first image features |
RyoheiHagimoto | 0:0e0631af0305 | 262 | @param features2 second image features |
RyoheiHagimoto | 0:0e0631af0305 | 263 | @param matches_info found matches |
RyoheiHagimoto | 0:0e0631af0305 | 264 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 265 | virtual void match(const ImageFeatures &features1, const ImageFeatures &features2, |
RyoheiHagimoto | 0:0e0631af0305 | 266 | MatchesInfo& matches_info) = 0; |
RyoheiHagimoto | 0:0e0631af0305 | 267 | |
RyoheiHagimoto | 0:0e0631af0305 | 268 | bool is_thread_safe_; |
RyoheiHagimoto | 0:0e0631af0305 | 269 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 270 | |
RyoheiHagimoto | 0:0e0631af0305 | 271 | /** @brief Features matcher which finds two best matches for each feature and leaves the best one only if the |
RyoheiHagimoto | 0:0e0631af0305 | 272 | ratio between descriptor distances is greater than the threshold match_conf |
RyoheiHagimoto | 0:0e0631af0305 | 273 | |
RyoheiHagimoto | 0:0e0631af0305 | 274 | @sa detail::FeaturesMatcher |
RyoheiHagimoto | 0:0e0631af0305 | 275 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 276 | class CV_EXPORTS BestOf2NearestMatcher : public FeaturesMatcher |
RyoheiHagimoto | 0:0e0631af0305 | 277 | { |
RyoheiHagimoto | 0:0e0631af0305 | 278 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 279 | /** @brief Constructs a "best of 2 nearest" matcher. |
RyoheiHagimoto | 0:0e0631af0305 | 280 | |
RyoheiHagimoto | 0:0e0631af0305 | 281 | @param try_use_gpu Should try to use GPU or not |
RyoheiHagimoto | 0:0e0631af0305 | 282 | @param match_conf Match distances ration threshold |
RyoheiHagimoto | 0:0e0631af0305 | 283 | @param num_matches_thresh1 Minimum number of matches required for the 2D projective transform |
RyoheiHagimoto | 0:0e0631af0305 | 284 | estimation used in the inliers classification step |
RyoheiHagimoto | 0:0e0631af0305 | 285 | @param num_matches_thresh2 Minimum number of matches required for the 2D projective transform |
RyoheiHagimoto | 0:0e0631af0305 | 286 | re-estimation on inliers |
RyoheiHagimoto | 0:0e0631af0305 | 287 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 288 | BestOf2NearestMatcher(bool try_use_gpu = false, float match_conf = 0.3f, int num_matches_thresh1 = 6, |
RyoheiHagimoto | 0:0e0631af0305 | 289 | int num_matches_thresh2 = 6); |
RyoheiHagimoto | 0:0e0631af0305 | 290 | |
RyoheiHagimoto | 0:0e0631af0305 | 291 | void collectGarbage(); |
RyoheiHagimoto | 0:0e0631af0305 | 292 | |
RyoheiHagimoto | 0:0e0631af0305 | 293 | protected: |
RyoheiHagimoto | 0:0e0631af0305 | 294 | void match(const ImageFeatures &features1, const ImageFeatures &features2, MatchesInfo &matches_info); |
RyoheiHagimoto | 0:0e0631af0305 | 295 | |
RyoheiHagimoto | 0:0e0631af0305 | 296 | int num_matches_thresh1_; |
RyoheiHagimoto | 0:0e0631af0305 | 297 | int num_matches_thresh2_; |
RyoheiHagimoto | 0:0e0631af0305 | 298 | Ptr<FeaturesMatcher> impl_; |
RyoheiHagimoto | 0:0e0631af0305 | 299 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 300 | |
RyoheiHagimoto | 0:0e0631af0305 | 301 | class CV_EXPORTS BestOf2NearestRangeMatcher : public BestOf2NearestMatcher |
RyoheiHagimoto | 0:0e0631af0305 | 302 | { |
RyoheiHagimoto | 0:0e0631af0305 | 303 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 304 | BestOf2NearestRangeMatcher(int range_width = 5, bool try_use_gpu = false, float match_conf = 0.3f, |
RyoheiHagimoto | 0:0e0631af0305 | 305 | int num_matches_thresh1 = 6, int num_matches_thresh2 = 6); |
RyoheiHagimoto | 0:0e0631af0305 | 306 | |
RyoheiHagimoto | 0:0e0631af0305 | 307 | void operator ()(const std::vector<ImageFeatures> &features, std::vector<MatchesInfo> &pairwise_matches, |
RyoheiHagimoto | 0:0e0631af0305 | 308 | const cv::UMat &mask = cv::UMat()); |
RyoheiHagimoto | 0:0e0631af0305 | 309 | |
RyoheiHagimoto | 0:0e0631af0305 | 310 | |
RyoheiHagimoto | 0:0e0631af0305 | 311 | protected: |
RyoheiHagimoto | 0:0e0631af0305 | 312 | int range_width_; |
RyoheiHagimoto | 0:0e0631af0305 | 313 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 314 | |
RyoheiHagimoto | 0:0e0631af0305 | 315 | /** @brief Features matcher similar to cv::detail::BestOf2NearestMatcher which |
RyoheiHagimoto | 0:0e0631af0305 | 316 | finds two best matches for each feature and leaves the best one only if the |
RyoheiHagimoto | 0:0e0631af0305 | 317 | ratio between descriptor distances is greater than the threshold match_conf. |
RyoheiHagimoto | 0:0e0631af0305 | 318 | |
RyoheiHagimoto | 0:0e0631af0305 | 319 | Unlike cv::detail::BestOf2NearestMatcher this matcher uses affine |
RyoheiHagimoto | 0:0e0631af0305 | 320 | transformation (affine trasformation estimate will be placed in matches_info). |
RyoheiHagimoto | 0:0e0631af0305 | 321 | |
RyoheiHagimoto | 0:0e0631af0305 | 322 | @sa cv::detail::FeaturesMatcher cv::detail::BestOf2NearestMatcher |
RyoheiHagimoto | 0:0e0631af0305 | 323 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 324 | class CV_EXPORTS AffineBestOf2NearestMatcher : public BestOf2NearestMatcher |
RyoheiHagimoto | 0:0e0631af0305 | 325 | { |
RyoheiHagimoto | 0:0e0631af0305 | 326 | public: |
RyoheiHagimoto | 0:0e0631af0305 | 327 | /** @brief Constructs a "best of 2 nearest" matcher that expects affine trasformation |
RyoheiHagimoto | 0:0e0631af0305 | 328 | between images |
RyoheiHagimoto | 0:0e0631af0305 | 329 | |
RyoheiHagimoto | 0:0e0631af0305 | 330 | @param full_affine whether to use full affine transformation with 6 degress of freedom or reduced |
RyoheiHagimoto | 0:0e0631af0305 | 331 | transformation with 4 degrees of freedom using only rotation, translation and uniform scaling |
RyoheiHagimoto | 0:0e0631af0305 | 332 | @param try_use_gpu Should try to use GPU or not |
RyoheiHagimoto | 0:0e0631af0305 | 333 | @param match_conf Match distances ration threshold |
RyoheiHagimoto | 0:0e0631af0305 | 334 | @param num_matches_thresh1 Minimum number of matches required for the 2D affine transform |
RyoheiHagimoto | 0:0e0631af0305 | 335 | estimation used in the inliers classification step |
RyoheiHagimoto | 0:0e0631af0305 | 336 | |
RyoheiHagimoto | 0:0e0631af0305 | 337 | @sa cv::estimateAffine2D cv::estimateAffinePartial2D |
RyoheiHagimoto | 0:0e0631af0305 | 338 | */ |
RyoheiHagimoto | 0:0e0631af0305 | 339 | AffineBestOf2NearestMatcher(bool full_affine = false, bool try_use_gpu = false, |
RyoheiHagimoto | 0:0e0631af0305 | 340 | float match_conf = 0.3f, int num_matches_thresh1 = 6) : |
RyoheiHagimoto | 0:0e0631af0305 | 341 | BestOf2NearestMatcher(try_use_gpu, match_conf, num_matches_thresh1, num_matches_thresh1), |
RyoheiHagimoto | 0:0e0631af0305 | 342 | full_affine_(full_affine) {} |
RyoheiHagimoto | 0:0e0631af0305 | 343 | |
RyoheiHagimoto | 0:0e0631af0305 | 344 | protected: |
RyoheiHagimoto | 0:0e0631af0305 | 345 | void match(const ImageFeatures &features1, const ImageFeatures &features2, MatchesInfo &matches_info); |
RyoheiHagimoto | 0:0e0631af0305 | 346 | |
RyoheiHagimoto | 0:0e0631af0305 | 347 | bool full_affine_; |
RyoheiHagimoto | 0:0e0631af0305 | 348 | }; |
RyoheiHagimoto | 0:0e0631af0305 | 349 | |
RyoheiHagimoto | 0:0e0631af0305 | 350 | //! @} stitching_match |
RyoheiHagimoto | 0:0e0631af0305 | 351 | |
RyoheiHagimoto | 0:0e0631af0305 | 352 | } // namespace detail |
RyoheiHagimoto | 0:0e0631af0305 | 353 | } // namespace cv |
RyoheiHagimoto | 0:0e0631af0305 | 354 | |
RyoheiHagimoto | 0:0e0631af0305 | 355 | #endif // OPENCV_STITCHING_MATCHERS_HPP |