OpenCV453
matchers.hpp
1/*M///////////////////////////////////////////////////////////////////////////////////////
2//
3// IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4//
5// By downloading, copying, installing or using the software you agree to this license.
6// If you do not agree to this license, do not download, install,
7// copy or use the software.
8//
9//
10// License Agreement
11// For Open Source Computer Vision Library
12//
13// Copyright (C) 2000-2008, Intel Corporation, all rights reserved.
14// Copyright (C) 2009, Willow Garage Inc., all rights reserved.
15// Third party copyrights are property of their respective owners.
16//
17// Redistribution and use in source and binary forms, with or without modification,
18// are permitted provided that the following conditions are met:
19//
20// * Redistribution's of source code must retain the above copyright notice,
21// this list of conditions and the following disclaimer.
22//
23// * Redistribution's in binary form must reproduce the above copyright notice,
24// this list of conditions and the following disclaimer in the documentation
25// and/or other materials provided with the distribution.
26//
27// * The name of the copyright holders may not be used to endorse or promote products
28// derived from this software without specific prior written permission.
29//
30// This software is provided by the copyright holders and contributors "as is" and
31// any express or implied warranties, including, but not limited to, the implied
32// warranties of merchantability and fitness for a particular purpose are disclaimed.
33// In no event shall the Intel Corporation or contributors be liable for any direct,
34// indirect, incidental, special, exemplary, or consequential damages
35// (including, but not limited to, procurement of substitute goods or services;
36// loss of use, data, or profits; or business interruption) however caused
37// and on any theory of liability, whether in contract, strict liability,
38// or tort (including negligence or otherwise) arising in any way out of
39// the use of this software, even if advised of the possibility of such damage.
40//
41//M*/
42
43#ifndef OPENCV_STITCHING_MATCHERS_HPP
44#define OPENCV_STITCHING_MATCHERS_HPP
45
46#include "opencv2/core.hpp"
47#include "opencv2/features2d.hpp"
48
49#include "opencv2/opencv_modules.hpp"
50
51namespace cv {
52namespace detail {
53
56
58struct CV_EXPORTS_W_SIMPLE ImageFeatures
59{
60 CV_PROP_RW int img_idx;
61 CV_PROP_RW Size img_size;
62 std::vector<KeyPoint> keypoints;
63 CV_PROP_RW UMat descriptors;
64 CV_WRAP std::vector<KeyPoint> getKeypoints() { return keypoints; };
65};
73CV_EXPORTS_W void computeImageFeatures(
74 const Ptr<Feature2D> &featuresFinder,
75 InputArrayOfArrays images,
76 CV_OUT std::vector<ImageFeatures> &features,
77 InputArrayOfArrays masks = noArray());
78
86CV_EXPORTS_AS(computeImageFeatures2) void computeImageFeatures(
87 const Ptr<Feature2D> &featuresFinder,
88 InputArray image,
89 CV_OUT ImageFeatures &features,
90 InputArray mask = noArray());
91
99struct CV_EXPORTS_W_SIMPLE MatchesInfo
100{
101 MatchesInfo();
102 MatchesInfo(const MatchesInfo &other);
103 MatchesInfo& operator =(const MatchesInfo &other);
104
105 CV_PROP_RW int src_img_idx;
106 CV_PROP_RW int dst_img_idx;
107 std::vector<DMatch> matches;
108 std::vector<uchar> inliers_mask;
109 CV_PROP_RW int num_inliers;
110 CV_PROP_RW Mat H;
111 CV_PROP_RW double confidence;
112 CV_WRAP std::vector<DMatch> getMatches() { return matches; };
113 CV_WRAP std::vector<uchar> getInliers() { return inliers_mask; };
114};
115
117class CV_EXPORTS_W FeaturesMatcher
118{
119public:
120 CV_WRAP virtual ~FeaturesMatcher() {}
121
127 CV_WRAP_AS(apply) void operator ()(const ImageFeatures &features1, const ImageFeatures &features2,
128 CV_OUT MatchesInfo& matches_info) { match(features1, features2, matches_info); }
129
140 CV_WRAP_AS(apply2) void operator ()(const std::vector<ImageFeatures> &features, CV_OUT std::vector<MatchesInfo> &pairwise_matches,
141 const cv::UMat &mask = cv::UMat());
142
145 CV_WRAP bool isThreadSafe() const { return is_thread_safe_; }
146
149 CV_WRAP virtual void collectGarbage() {}
150
151protected:
152 FeaturesMatcher(bool is_thread_safe = false) : is_thread_safe_(is_thread_safe) {}
153
161 virtual void match(const ImageFeatures &features1, const ImageFeatures &features2,
162 MatchesInfo& matches_info) = 0;
163
164 bool is_thread_safe_;
165};
166
172class CV_EXPORTS_W BestOf2NearestMatcher : public FeaturesMatcher
173{
174public:
184 CV_WRAP BestOf2NearestMatcher(bool try_use_gpu = false, float match_conf = 0.3f, int num_matches_thresh1 = 6,
185 int num_matches_thresh2 = 6);
186
187 CV_WRAP void collectGarbage() CV_OVERRIDE;
188 CV_WRAP static Ptr<BestOf2NearestMatcher> create(bool try_use_gpu = false, float match_conf = 0.3f, int num_matches_thresh1 = 6,
189 int num_matches_thresh2 = 6);
190
191protected:
192
193 void match(const ImageFeatures &features1, const ImageFeatures &features2, MatchesInfo &matches_info) CV_OVERRIDE;
194 int num_matches_thresh1_;
195 int num_matches_thresh2_;
196 Ptr<FeaturesMatcher> impl_;
197};
198
200{
201public:
202 CV_WRAP BestOf2NearestRangeMatcher(int range_width = 5, bool try_use_gpu = false, float match_conf = 0.3f,
203 int num_matches_thresh1 = 6, int num_matches_thresh2 = 6);
204
205 void operator ()(const std::vector<ImageFeatures> &features, std::vector<MatchesInfo> &pairwise_matches,
206 const cv::UMat &mask = cv::UMat());
207
208
209protected:
210 int range_width_;
211};
212
223{
224public:
237 CV_WRAP AffineBestOf2NearestMatcher(bool full_affine = false, bool try_use_gpu = false,
238 float match_conf = 0.3f, int num_matches_thresh1 = 6) :
239 BestOf2NearestMatcher(try_use_gpu, match_conf, num_matches_thresh1, num_matches_thresh1),
240 full_affine_(full_affine) {}
241
242protected:
243 void match(const ImageFeatures &features1, const ImageFeatures &features2, MatchesInfo &matches_info) CV_OVERRIDE;
244
245 bool full_affine_;
246};
247
249
250} // namespace detail
251} // namespace cv
252
253#endif // OPENCV_STITCHING_MATCHERS_HPP
n-dimensional dense array class
Definition: mat.hpp:802
Template class for specifying the size of an image or rectangle.
Definition: core/types.hpp:316
Definition: mat.hpp:2402
Features matcher similar to cv::detail::BestOf2NearestMatcher which finds two best matches for each f...
Definition: matchers.hpp:223
void match(const ImageFeatures &features1, const ImageFeatures &features2, MatchesInfo &matches_info) CV_OVERRIDE
This method must implement matching logic in order to make the wrappers detail::FeaturesMatcher::oper...
Features matcher which finds two best matches for each feature and leaves the best one only if the ra...
Definition: matchers.hpp:173
Definition: matchers.hpp:200
Feature matchers base class.
Definition: matchers.hpp:118
virtual void match(const ImageFeatures &features1, const ImageFeatures &features2, MatchesInfo &matches_info)=0
This method must implement matching logic in order to make the wrappers detail::FeaturesMatcher::oper...
CV_WRAP_AS(apply) void operator()(const ImageFeatures &features1
CV_EXPORTS_AS(calibrateCameraExtended) double calibrateCamera(InputArrayOfArrays objectPoints
Finds the camera intrinsic and extrinsic parameters from several views of a calibration pattern.
CV_EXPORTS CV_WRAP_AS(goodFeaturesToTrackWithQuality) void goodFeaturesToTrack(InputArray image
Same as above, but returns also quality measure of the detected corners.
CV_EXPORTS_W void computeImageFeatures(const Ptr< Feature2D > &featuresFinder, InputArrayOfArrays images, CV_OUT std::vector< ImageFeatures > &features, InputArrayOfArrays masks=noArray())
"black box" representation of the file storage associated with a file on disk.
Definition: aruco.hpp:75
Definition: cvstd_wrapper.hpp:74
Structure containing image keypoints and descriptors.
Definition: matchers.hpp:59
Structure containing information about matches between two images.
Definition: matchers.hpp:100
std::vector< uchar > inliers_mask
Geometrically consistent matches mask
Definition: matchers.hpp:108