1 /*M///////////////////////////////////////////////////////////////////////////////////////
3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
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.
11 // For Open Source Computer Vision Library
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.
17 // Redistribution and use in source and binary forms, with or without modification,
18 // are permitted provided that the following conditions are met:
20 // * Redistribution's of source code must retain the above copyright notice,
21 // this list of conditions and the following disclaimer.
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.
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.
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.
43 #include "precomp.hpp"
47 Ptr<Feature2D> Feature2D::create( const String& feature2DType )
49 return Algorithm::create<Feature2D>("Feature2D." + feature2DType);
52 /////////////////////// AlgorithmInfo for various detector & descriptors ////////////////////////////
55 All the AlgorithmInfo-related stuff should be in the same file as initModule_features2d().
56 Otherwise, linker may throw away some seemingly unused stuff.
59 CV_INIT_ALGORITHM(BRISK, "Feature2D.BRISK",
60 obj.info()->addParam(obj, "thres", obj.threshold);
61 obj.info()->addParam(obj, "octaves", obj.octaves));
63 ///////////////////////////////////////////////////////////////////////////////////////////////////////////
65 CV_INIT_ALGORITHM(BriefDescriptorExtractor, "Feature2D.BRIEF",
66 obj.info()->addParam(obj, "bytes", obj.bytes_));
68 ///////////////////////////////////////////////////////////////////////////////////////////////////////////
70 CV_INIT_ALGORITHM(FastFeatureDetector, "Feature2D.FAST",
71 obj.info()->addParam(obj, "threshold", obj.threshold);
72 obj.info()->addParam(obj, "nonmaxSuppression", obj.nonmaxSuppression);
73 obj.info()->addParam(obj, "type", obj.type));
75 ///////////////////////////////////////////////////////////////////////////////////////////////////////////
77 CV_INIT_ALGORITHM(StarDetector, "Feature2D.STAR",
78 obj.info()->addParam(obj, "maxSize", obj.maxSize);
79 obj.info()->addParam(obj, "responseThreshold", obj.responseThreshold);
80 obj.info()->addParam(obj, "lineThresholdProjected", obj.lineThresholdProjected);
81 obj.info()->addParam(obj, "lineThresholdBinarized", obj.lineThresholdBinarized);
82 obj.info()->addParam(obj, "suppressNonmaxSize", obj.suppressNonmaxSize));
84 ///////////////////////////////////////////////////////////////////////////////////////////////////////////
86 CV_INIT_ALGORITHM(MSER, "Feature2D.MSER",
87 obj.info()->addParam(obj, "delta", obj.delta);
88 obj.info()->addParam(obj, "minArea", obj.minArea);
89 obj.info()->addParam(obj, "maxArea", obj.maxArea);
90 obj.info()->addParam(obj, "maxVariation", obj.maxVariation);
91 obj.info()->addParam(obj, "minDiversity", obj.minDiversity);
92 obj.info()->addParam(obj, "maxEvolution", obj.maxEvolution);
93 obj.info()->addParam(obj, "areaThreshold", obj.areaThreshold);
94 obj.info()->addParam(obj, "minMargin", obj.minMargin);
95 obj.info()->addParam(obj, "edgeBlurSize", obj.edgeBlurSize));
97 ///////////////////////////////////////////////////////////////////////////////////////////////////////////
99 CV_INIT_ALGORITHM(ORB, "Feature2D.ORB",
100 obj.info()->addParam(obj, "nFeatures", obj.nfeatures);
101 obj.info()->addParam(obj, "scaleFactor", obj.scaleFactor);
102 obj.info()->addParam(obj, "nLevels", obj.nlevels);
103 obj.info()->addParam(obj, "firstLevel", obj.firstLevel);
104 obj.info()->addParam(obj, "edgeThreshold", obj.edgeThreshold);
105 obj.info()->addParam(obj, "patchSize", obj.patchSize);
106 obj.info()->addParam(obj, "WTA_K", obj.WTA_K);
107 obj.info()->addParam(obj, "scoreType", obj.scoreType));
109 ///////////////////////////////////////////////////////////////////////////////////////////////////////////
111 CV_INIT_ALGORITHM(FREAK, "Feature2D.FREAK",
112 obj.info()->addParam(obj, "orientationNormalized", obj.orientationNormalized);
113 obj.info()->addParam(obj, "scaleNormalized", obj.scaleNormalized);
114 obj.info()->addParam(obj, "patternScale", obj.patternScale);
115 obj.info()->addParam(obj, "nbOctave", obj.nOctaves));
117 ///////////////////////////////////////////////////////////////////////////////////////////////////////////
119 CV_INIT_ALGORITHM(GFTTDetector, "Feature2D.GFTT",
120 obj.info()->addParam(obj, "nfeatures", obj.nfeatures);
121 obj.info()->addParam(obj, "qualityLevel", obj.qualityLevel);
122 obj.info()->addParam(obj, "minDistance", obj.minDistance);
123 obj.info()->addParam(obj, "useHarrisDetector", obj.useHarrisDetector);
124 obj.info()->addParam(obj, "k", obj.k));
126 ///////////////////////////////////////////////////////////////////////////////////////////////////////////
128 CV_INIT_ALGORITHM(SimpleBlobDetector, "Feature2D.SimpleBlob",
129 obj.info()->addParam(obj, "thresholdStep", obj.params.thresholdStep);
130 obj.info()->addParam(obj, "minThreshold", obj.params.minThreshold);
131 obj.info()->addParam(obj, "maxThreshold", obj.params.maxThreshold);
132 obj.info()->addParam_(obj, "minRepeatability", (sizeof(size_t) == sizeof(uint64))?Param::UINT64 : Param::UNSIGNED_INT, &obj.params.minRepeatability, false, 0, 0);
133 obj.info()->addParam(obj, "minDistBetweenBlobs", obj.params.minDistBetweenBlobs);
134 obj.info()->addParam(obj, "filterByColor", obj.params.filterByColor);
135 obj.info()->addParam(obj, "blobColor", obj.params.blobColor);
136 obj.info()->addParam(obj, "filterByArea", obj.params.filterByArea);
137 obj.info()->addParam(obj, "maxArea", obj.params.maxArea);
138 obj.info()->addParam(obj, "filterByCircularity", obj.params.filterByCircularity);
139 obj.info()->addParam(obj, "maxCircularity", obj.params.maxCircularity);
140 obj.info()->addParam(obj, "filterByInertia", obj.params.filterByInertia);
141 obj.info()->addParam(obj, "maxInertiaRatio", obj.params.maxInertiaRatio);
142 obj.info()->addParam(obj, "filterByConvexity", obj.params.filterByConvexity);
143 obj.info()->addParam(obj, "maxConvexity", obj.params.maxConvexity);
146 ///////////////////////////////////////////////////////////////////////////////////////////////////////////
148 class CV_EXPORTS HarrisDetector : public GFTTDetector
151 HarrisDetector( int maxCorners=1000, double qualityLevel=0.01, double minDistance=1,
152 int blockSize=3, bool useHarrisDetector=true, double k=0.04 );
153 AlgorithmInfo* info() const;
156 inline HarrisDetector::HarrisDetector( int _maxCorners, double _qualityLevel, double _minDistance,
157 int _blockSize, bool _useHarrisDetector, double _k )
158 : GFTTDetector( _maxCorners, _qualityLevel, _minDistance, _blockSize, _useHarrisDetector, _k ) {}
160 CV_INIT_ALGORITHM(HarrisDetector, "Feature2D.HARRIS",
161 obj.info()->addParam(obj, "nfeatures", obj.nfeatures);
162 obj.info()->addParam(obj, "qualityLevel", obj.qualityLevel);
163 obj.info()->addParam(obj, "minDistance", obj.minDistance);
164 obj.info()->addParam(obj, "useHarrisDetector", obj.useHarrisDetector);
165 obj.info()->addParam(obj, "k", obj.k));
167 ////////////////////////////////////////////////////////////////////////////////////////////////////////////
169 CV_INIT_ALGORITHM(DenseFeatureDetector, "Feature2D.Dense",
170 obj.info()->addParam(obj, "initFeatureScale", obj.initFeatureScale);
171 obj.info()->addParam(obj, "featureScaleLevels", obj.featureScaleLevels);
172 obj.info()->addParam(obj, "featureScaleMul", obj.featureScaleMul);
173 obj.info()->addParam(obj, "initXyStep", obj.initXyStep);
174 obj.info()->addParam(obj, "initImgBound", obj.initImgBound);
175 obj.info()->addParam(obj, "varyXyStepWithScale", obj.varyXyStepWithScale);
176 obj.info()->addParam(obj, "varyImgBoundWithScale", obj.varyImgBoundWithScale));
178 CV_INIT_ALGORITHM(GridAdaptedFeatureDetector, "Feature2D.Grid",
179 obj.info()->addParam<FeatureDetector>(obj, "detector", obj.detector, false, 0, 0); // Extra params added to avoid VS2013 fatal error in opencv2/core.hpp (decl. of addParam)
180 obj.info()->addParam(obj, "maxTotalKeypoints", obj.maxTotalKeypoints);
181 obj.info()->addParam(obj, "gridRows", obj.gridRows);
182 obj.info()->addParam(obj, "gridCols", obj.gridCols));
184 ////////////////////////////////////////////////////////////////////////////////////////////////////////////
186 CV_INIT_ALGORITHM(BFMatcher, "DescriptorMatcher.BFMatcher",
187 obj.info()->addParam(obj, "normType", obj.normType);
188 obj.info()->addParam(obj, "crossCheck", obj.crossCheck));
190 CV_INIT_ALGORITHM(FlannBasedMatcher, "DescriptorMatcher.FlannBasedMatcher",);
192 ///////////////////////////////////////////////////////////////////////////////////////////////////////////
194 bool cv::initModule_features2d(void)
197 all &= !BriefDescriptorExtractor_info_auto.name().empty();
198 all &= !BRISK_info_auto.name().empty();
199 all &= !FastFeatureDetector_info_auto.name().empty();
200 all &= !StarDetector_info_auto.name().empty();
201 all &= !MSER_info_auto.name().empty();
202 all &= !FREAK_info_auto.name().empty();
203 all &= !ORB_info_auto.name().empty();
204 all &= !GFTTDetector_info_auto.name().empty();
205 all &= !HarrisDetector_info_auto.name().empty();
206 all &= !DenseFeatureDetector_info_auto.name().empty();
207 all &= !GridAdaptedFeatureDetector_info_auto.name().empty();
208 all &= !BFMatcher_info_auto.name().empty();
209 all &= !FlannBasedMatcher_info_auto.name().empty();