RTAB-Map 0.23.10
Real-Time Appearance-Based Mapping
Loading...
Searching...
No Matches
Features2d.h
1/*
2Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, are permitted provided that the following conditions are met:
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in the
11 documentation and/or other materials provided with the distribution.
12 * Neither the name of the Universite de Sherbrooke nor the
13 names of its contributors may be used to endorse or promote products
14 derived from this software without specific prior written permission.
15
16THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*/
27
28#ifndef FEATURES2D_H_
29#define FEATURES2D_H_
30
31#include "rtabmap/core/rtabmap_core_export.h" // DLL export/import defines
32
33#include <opencv2/highgui/highgui.hpp>
34#include <opencv2/core/core.hpp>
35#if CV_MAJOR_VERSION < 5
36#include <opencv2/features2d/features2d.hpp>
37#else
38#include <opencv2/features.hpp>
39#endif
40#include <list>
41#include <numeric>
42#include "rtabmap/core/Parameters.h"
43#include "rtabmap/core/SensorData.h"
44
45#if CV_MAJOR_VERSION < 3
46namespace cv{
47class SURF;
48class SIFT;
49namespace gpu {
50 class SURF_GPU;
51 class ORB_GPU;
52 class FAST_GPU;
53 class GoodFeaturesToTrackDetector_GPU;
54}
55}
56typedef cv::SIFT CV_SIFT;
57typedef cv::SURF CV_SURF;
58typedef cv::FastFeatureDetector CV_FAST;
59typedef cv::FREAK CV_FREAK;
60typedef cv::GFTTDetector CV_GFTT;
61typedef cv::BriefDescriptorExtractor CV_BRIEF;
62typedef cv::BRISK CV_BRISK;
63typedef cv::gpu::SURF_GPU CV_SURF_GPU;
64typedef cv::gpu::ORB_GPU CV_ORB_GPU;
65typedef cv::gpu::FAST_GPU CV_FAST_GPU;
66typedef cv::gpu::GoodFeaturesToTrackDetector_GPU CV_GFTT_GPU;
67#else
68namespace cv{
69namespace xfeatures2d {
70class FREAK;
71class DAISY;
72class BriefDescriptorExtractor;
73#if (CV_MAJOR_VERSION == 4 && CV_MINOR_VERSION <= 3) || (CV_MAJOR_VERSION == 3 && (CV_MINOR_VERSION < 4 || (CV_MINOR_VERSION==4 && CV_SUBMINOR_VERSION<11)))
74class SIFT;
75#endif
76class SURF;
77#if (CV_MAJOR_VERSION == 5)
78class BRISK;
79class KAZE;
80#endif
81}
82namespace cuda {
83class FastFeatureDetector;
84class ORB;
85class SURF_CUDA;
86class CornersDetector;
87}
88}
89#if (CV_MAJOR_VERSION == 4 && CV_MINOR_VERSION <= 3) || (CV_MAJOR_VERSION == 3 && (CV_MINOR_VERSION < 4 || (CV_MINOR_VERSION==4 && CV_SUBMINOR_VERSION<11)))
90typedef cv::xfeatures2d::SIFT CV_SIFT;
91#else
92typedef cv::SIFT CV_SIFT; // SIFT is back in features2d since 4.4.0 / 3.4.11
93#endif
94typedef cv::xfeatures2d::SURF CV_SURF;
95typedef cv::FastFeatureDetector CV_FAST;
96typedef cv::xfeatures2d::FREAK CV_FREAK;
97typedef cv::xfeatures2d::DAISY CV_DAISY;
98typedef cv::GFTTDetector CV_GFTT;
99typedef cv::xfeatures2d::BriefDescriptorExtractor CV_BRIEF;
100#if (CV_MAJOR_VERSION < 5)
101typedef cv::BRISK CV_BRISK;
102typedef cv::KAZE CV_KAZE;
103#else
104typedef cv::xfeatures2d::BRISK CV_BRISK;
105typedef cv::xfeatures2d::KAZE CV_KAZE;
106#endif
107typedef cv::ORB CV_ORB;
108typedef cv::cuda::SURF_CUDA CV_SURF_GPU;
109typedef cv::cuda::ORB CV_ORB_GPU;
110typedef cv::cuda::FastFeatureDetector CV_FAST_GPU;
111typedef cv::cuda::CornersDetector CV_GFTT_GPU;
112#endif
113
114// CudaSift fork: https://github.com/matlabbe/CudaSift
115class SiftData;
116
117namespace rtabmap {
118
119class ORBextractor;
120class SPDetector;
121class SPDetectorRpautrat;
122
123class Stereo;
124#if CV_MAJOR_VERSION < 3
125class CV_ORB;
126#endif
127
145class RTABMAP_CORE_EXPORT Feature2D {
146public:
148 enum Type {kFeatureUndef=-1,
149 kFeatureSurf=0,
150 kFeatureSift=1,
151 kFeatureOrb=2,
152 kFeatureFastFreak=3,
153 kFeatureFastBrief=4,
154 kFeatureGfttFreak=5,
155 kFeatureGfttBrief=6,
156 kFeatureBrisk=7,
157 kFeatureGfttOrb=8, //new 0.10.11
158 kFeatureKaze=9, //new 0.13.2
159 kFeatureOrbOctree=10, //new 0.19.2
160 kFeatureSuperPointTorch=11, //new 0.19.7
161 kFeatureSurfFreak=12, //new 0.20.4
162 kFeatureGfttDaisy=13, //new 0.20.6
163 kFeatureSurfDaisy=14, //new 0.20.6
164 kFeaturePyDetector=15, //new 0.20.8
165 kFeatureSuperPointRpautrat=16, // new 0.23.3
166 kFeatureEnd}; // Sentinel: always keep last. Used to iterate through types.
167
169 static std::string typeName(Type type)
170 {
171 switch(type){
172 case kFeatureSurf:
173 return "SURF";
174 case kFeatureSift:
175 return "SIFT";
176 case kFeatureOrb:
177 return "ORB";
178 case kFeatureFastFreak:
179 return "FAST+FREAK";
180 case kFeatureFastBrief:
181 return "FAST+BRIEF";
182 case kFeatureGfttFreak:
183 return "GFTT+Freak";
184 case kFeatureGfttBrief:
185 return "GFTT+Brief";
186 case kFeatureBrisk:
187 return "BRISK";
188 case kFeatureGfttOrb:
189 return "GFTT+ORB";
190 case kFeatureKaze:
191 return "KAZE";
192 case kFeatureOrbOctree:
193 return "ORB-OCTREE";
194 case kFeatureSuperPointTorch:
195 return "SUPERPOINT";
196 case kFeatureSurfFreak:
197 return "SURF+Freak";
198 case kFeatureGfttDaisy:
199 return "GFTT+Daisy";
200 case kFeatureSurfDaisy:
201 return "SURF+Daisy";
202 case kFeaturePyDetector:
203 return "PyDetector";
204 case kFeatureSuperPointRpautrat:
205 return "SUPERPOINT-RPAUTRAT";
206 default:
207 return "Unknown";
208 }
209 }
210
212 static Feature2D * create(const ParametersMap & parameters = ParametersMap());
214 static Feature2D * create(Feature2D::Type type, const ParametersMap & parameters = ParametersMap());
215
217 static bool isAvailable(Feature2D::Type type);
218
221 std::vector<cv::KeyPoint> & keypoints,
222 const cv::Mat & depth,
223 float minDepth,
224 float maxDepth);
225 static void filterKeypointsByDepth(
226 std::vector<cv::KeyPoint> & keypoints,
227 cv::Mat & descriptors,
228 const cv::Mat & depth,
229 float minDepth,
230 float maxDepth);
231 static void filterKeypointsByDepth(
232 std::vector<cv::KeyPoint> & keypoints,
233 cv::Mat & descriptors,
234 std::vector<cv::Point3f> & keypoints3D,
235 float minDepth,
236 float maxDepth);
237
240 std::vector<cv::KeyPoint> & keypoints,
241 const cv::Mat & disparity,
242 float minDisparity);
243 static void filterKeypointsByDisparity(
244 std::vector<cv::KeyPoint> & keypoints,
245 cv::Mat & descriptors,
246 const cv::Mat & disparity,
247 float minDisparity);
248
250 static void limitKeypoints(std::vector<cv::KeyPoint> & keypoints, int maxKeypoints, const cv::Size & imageSize = cv::Size(), bool ssc = false);
251 static void limitKeypoints(std::vector<cv::KeyPoint> & keypoints, cv::Mat & descriptors, int maxKeypoints, const cv::Size & imageSize = cv::Size(), bool ssc = false);
252 static void limitKeypoints(std::vector<cv::KeyPoint> & keypoints, std::vector<cv::Point3f> & keypoints3D, cv::Mat & descriptors, int maxKeypoints, const cv::Size & imageSize = cv::Size(), bool ssc = false);
253 static void limitKeypoints(const std::vector<cv::KeyPoint> & keypoints, std::vector<bool> & inliers, int maxKeypoints, const cv::Size & imageSize = cv::Size(), bool ssc = false);
254 static void limitKeypoints(const std::vector<cv::KeyPoint> & keypoints, std::vector<bool> & inliers, int maxKeypoints, const cv::Size & imageSize, int gridRows, int gridCols, bool ssc = false);
255
257 static cv::Rect computeRoi(const cv::Mat & image, const std::string & roiRatios);
258 static cv::Rect computeRoi(const cv::Mat & image, const std::vector<float> & roiRatios);
259
260 int getMaxFeatures() const {return maxFeatures_;}
261 bool getSSC() const {return SSC_;}
262 float getMinDepth() const {return _minDepth;}
263 float getMaxDepth() const {return _maxDepth;}
264 int getGridRows() const {return gridRows_;}
265 int getGridCols() const {return gridCols_;}
266
267public:
268 virtual ~Feature2D();
269
271 std::vector<cv::KeyPoint> generateKeypoints(
272 const cv::Mat & image,
273 const cv::Mat & mask = cv::Mat());
276 const cv::Mat & image,
277 std::vector<cv::KeyPoint> & keypoints) const;
279 std::vector<cv::Point3f> generateKeypoints3D(
280 const SensorData & data,
281 const std::vector<cv::KeyPoint> & keypoints) const;
282
283 virtual void parseParameters(const ParametersMap & parameters);
284 virtual const ParametersMap & getParameters() const {return parameters_;}
285 virtual Feature2D::Type getType() const = 0;
286
294 virtual bool isGpuAvailable() const {return false;}
295
296protected:
297 Feature2D(const ParametersMap & parameters = ParametersMap());
298
299private:
300 virtual std::vector<cv::KeyPoint> generateKeypointsImpl(const cv::Mat & image, const cv::Rect & roi, const cv::Mat & mask = cv::Mat()) = 0;
301 virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const = 0;
302
303private:
304 ParametersMap parameters_;
305 int maxFeatures_;
306 bool SSC_;
307 float _maxDepth; // 0=inf
308 float _minDepth;
309 std::vector<float> _roiRatios; // size 4
310 int _subPixWinSize;
311 int _subPixIterations;
312 double _subPixEps;
313 int gridRows_;
314 int gridCols_;
315 // Stereo stuff
316 Stereo * _stereo;
317};
318
320class RTABMAP_CORE_EXPORT SURF : public Feature2D
321{
322public:
323 SURF(const ParametersMap & parameters = ParametersMap());
324 virtual ~SURF();
325
326 virtual void parseParameters(const ParametersMap & parameters) override;
327 virtual Feature2D::Type getType() const override {return kFeatureSurf;}
328 virtual bool isGpuAvailable() const override;
329
330private:
331 virtual std::vector<cv::KeyPoint> generateKeypointsImpl(const cv::Mat & image, const cv::Rect & roi, const cv::Mat & mask = cv::Mat()) override;
332 virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
333
334private:
335 double hessianThreshold_;
336 int nOctaves_;
337 int nOctaveLayers_;
338 bool extended_;
339 bool upright_;
340 float gpuKeypointsRatio_;
341 bool gpuVersion_;
342
343 cv::Ptr<CV_SURF> _surf;
344 cv::Ptr<CV_SURF_GPU> _gpuSurf;
345};
346
348class RTABMAP_CORE_EXPORT SIFT : public Feature2D
349{
350public:
351 SIFT(const ParametersMap & parameters = ParametersMap());
352 virtual ~SIFT();
353
354 virtual void parseParameters(const ParametersMap & parameters) override;
355 virtual Feature2D::Type getType() const override {return kFeatureSift;}
356 virtual bool isGpuAvailable() const override;
357
358private:
359 virtual std::vector<cv::KeyPoint> generateKeypointsImpl(const cv::Mat & image, const cv::Rect & roi, const cv::Mat & mask = cv::Mat()) override;
360 virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
361
362private:
363 int nOctaveLayers_;
364 double contrastThreshold_;
365 double edgeThreshold_;
366 double sigma_;
367 bool preciseUpscale_;
368 bool rootSIFT_;
369 bool gpu_;
370 float gaussianThreshold_;
371 float maxGaussianThreshold_;
372 bool upscale_;
373
374 cv::Ptr<CV_SIFT> sift_;
375 SiftData * cudaSiftData_;
376 float * cudaSiftMemory_;
377 cv::Size cudaSiftMemorySize_;
378 cv::Mat cudaSiftDescriptors_;
379 bool cudaSiftUpscaling_;
380};
381
383class RTABMAP_CORE_EXPORT ORB : public Feature2D
384{
385public:
386 ORB(const ParametersMap & parameters = ParametersMap());
387 virtual ~ORB();
388
389 virtual void parseParameters(const ParametersMap & parameters) override;
390 virtual Feature2D::Type getType() const override {return kFeatureOrb;}
391 virtual bool isGpuAvailable() const override;
392
393private:
394 virtual std::vector<cv::KeyPoint> generateKeypointsImpl(const cv::Mat & image, const cv::Rect & roi, const cv::Mat & mask = cv::Mat()) override;
395 virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
396
397private:
398 float scaleFactor_;
399 int nLevels_;
400 int edgeThreshold_;
401 int firstLevel_;
402 int WTA_K_;
403 int scoreType_;
404 int patchSize_;
405 bool gpu_;
406
407 int fastThreshold_;
408 bool nonmaxSuppresion_;
409
410 cv::Ptr<CV_ORB> _orb;
411 cv::Ptr<CV_ORB_GPU> _gpuOrb;
412};
413
415class RTABMAP_CORE_EXPORT FAST : public Feature2D
416{
417public:
418 FAST(const ParametersMap & parameters = ParametersMap());
419 virtual ~FAST();
420
421 virtual void parseParameters(const ParametersMap & parameters) override;
422 virtual Feature2D::Type getType() const override {return kFeatureUndef;}
423 virtual bool isGpuAvailable() const override;
424
425private:
426 virtual std::vector<cv::KeyPoint> generateKeypointsImpl(const cv::Mat & image, const cv::Rect & roi, const cv::Mat & mask = cv::Mat()) override;
427 virtual cv::Mat generateDescriptorsImpl(const cv::Mat &, std::vector<cv::KeyPoint> &) const override {return cv::Mat();}
428
429private:
430 int threshold_;
431 bool nonmaxSuppression_;
432 bool gpu_;
433 double gpuKeypointsRatio_;
434 int minThreshold_;
435 int maxThreshold_;
436 int gridRows_;
437 int gridCols_;
438 int fastCV_;
439
440 bool fastCVinit_;
441 int fastCVMaxFeatures_;
442 int fastCVLastImageHeight_;
443 uint32_t* fastCVCorners_= NULL;
444 uint32_t* fastCVCornerScores_ = NULL;
445 void* fastCVTempBuf_ = NULL;
446
447 cv::Ptr<cv::FeatureDetector> _fast;
448 cv::Ptr<CV_FAST_GPU> _gpuFast;
449};
450
452class RTABMAP_CORE_EXPORT FAST_BRIEF : public FAST
453{
454public:
455 FAST_BRIEF(const ParametersMap & parameters = ParametersMap());
456 virtual ~FAST_BRIEF();
457
458 virtual void parseParameters(const ParametersMap & parameters) override;
459 virtual Feature2D::Type getType() const override {return kFeatureFastBrief;}
460
461private:
462 virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
463
464private:
465 int bytes_;
466
467 cv::Ptr<CV_BRIEF> _brief;
468};
469
471class RTABMAP_CORE_EXPORT FAST_FREAK : public FAST
472{
473public:
474 FAST_FREAK(const ParametersMap & parameters = ParametersMap());
475 virtual ~FAST_FREAK();
476
477 virtual void parseParameters(const ParametersMap & parameters) override;
478 virtual Feature2D::Type getType() const override {return kFeatureFastFreak;}
479
480private:
481 virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
482
483private:
484 bool orientationNormalized_;
485 bool scaleNormalized_;
486 float patternScale_;
487 int nOctaves_;
488
489 cv::Ptr<CV_FREAK> _freak;
490};
491
493class RTABMAP_CORE_EXPORT GFTT : public Feature2D
494{
495public:
496 GFTT(const ParametersMap & parameters = ParametersMap());
497 virtual ~GFTT();
498
499 virtual void parseParameters(const ParametersMap & parameters) override;
500 virtual bool isGpuAvailable() const override;
501
502private:
503 virtual std::vector<cv::KeyPoint> generateKeypointsImpl(const cv::Mat & image, const cv::Rect & roi, const cv::Mat & mask = cv::Mat()) override;
504
505private:
506 double _qualityLevel;
507 double _minDistance;
508 int _blockSize;
509 bool _useHarrisDetector;
510 double _k;
511 bool _gpu;
512
513 cv::Ptr<CV_GFTT> _gftt;
514 cv::Ptr<CV_GFTT_GPU> _gpuGftt;
515};
516
518class RTABMAP_CORE_EXPORT GFTT_BRIEF : public GFTT
519{
520public:
521 GFTT_BRIEF(const ParametersMap & parameters = ParametersMap());
522 virtual ~GFTT_BRIEF();
523
524 virtual void parseParameters(const ParametersMap & parameters) override;
525 virtual Feature2D::Type getType() const override {return kFeatureGfttBrief;}
526
527private:
528 virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
529
530private:
531 int bytes_;
532
533 cv::Ptr<CV_BRIEF> _brief;
534};
535
537class RTABMAP_CORE_EXPORT GFTT_FREAK : public GFTT
538{
539public:
540 GFTT_FREAK(const ParametersMap & parameters = ParametersMap());
541 virtual ~GFTT_FREAK();
542
543 virtual void parseParameters(const ParametersMap & parameters) override;
544 virtual Feature2D::Type getType() const override {return kFeatureGfttFreak;}
545
546private:
547 virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
548
549private:
550 bool orientationNormalized_;
551 bool scaleNormalized_;
552 float patternScale_;
553 int nOctaves_;
554
555 cv::Ptr<CV_FREAK> _freak;
556};
557
559class RTABMAP_CORE_EXPORT SURF_FREAK : public SURF
560{
561public:
562 SURF_FREAK(const ParametersMap & parameters = ParametersMap());
563 virtual ~SURF_FREAK();
564
565 virtual void parseParameters(const ParametersMap & parameters) override;
566 virtual Feature2D::Type getType() const override {return kFeatureSurfFreak;}
567
568private:
569 virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
570
571private:
572 bool orientationNormalized_;
573 bool scaleNormalized_;
574 float patternScale_;
575 int nOctaves_;
576
577 cv::Ptr<CV_FREAK> _freak;
578};
579
581class RTABMAP_CORE_EXPORT GFTT_ORB : public GFTT
582{
583public:
584 GFTT_ORB(const ParametersMap & parameters = ParametersMap());
585 virtual ~GFTT_ORB();
586
587 virtual void parseParameters(const ParametersMap & parameters) override;
588 virtual Feature2D::Type getType() const override {return kFeatureGfttOrb;}
589
590private:
591 virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
592
593private:
594 ORB _orb;
595};
596
598class RTABMAP_CORE_EXPORT BRISK : public Feature2D
599{
600public:
601 BRISK(const ParametersMap & parameters = ParametersMap());
602 virtual ~BRISK();
603
604 virtual void parseParameters(const ParametersMap & parameters) override;
605 virtual Feature2D::Type getType() const override {return kFeatureBrisk;}
606
607private:
608 virtual std::vector<cv::KeyPoint> generateKeypointsImpl(const cv::Mat & image, const cv::Rect & roi, const cv::Mat & mask = cv::Mat()) override;
609 virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
610
611private:
612 int thresh_;
613 int octaves_;
614 float patternScale_;
615
616 cv::Ptr<CV_BRISK> brisk_;
617};
618
620class RTABMAP_CORE_EXPORT KAZE : public Feature2D
621{
622public:
623 KAZE(const ParametersMap & parameters = ParametersMap());
624 virtual ~KAZE();
625
626 virtual void parseParameters(const ParametersMap & parameters) override;
627 virtual Feature2D::Type getType() const override { return kFeatureKaze; }
628
629private:
630 virtual std::vector<cv::KeyPoint> generateKeypointsImpl(const cv::Mat & image, const cv::Rect & roi, const cv::Mat & mask = cv::Mat()) override;
631 virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
632
633private:
634 bool extended_;
635 bool upright_;
636 float threshold_;
637 int nOctaves_;
638 int nOctaveLayers_;
639 int diffusivity_;
640
641#if CV_MAJOR_VERSION > 2
642 cv::Ptr<CV_KAZE> kaze_;
643#endif
644};
645
647class RTABMAP_CORE_EXPORT ORBOctree : public Feature2D
648{
649public:
650 ORBOctree(const ParametersMap & parameters = ParametersMap());
651 virtual ~ORBOctree();
652
653 virtual void parseParameters(const ParametersMap & parameters) override;
654 virtual Feature2D::Type getType() const override {return kFeatureOrbOctree;}
655
656private:
657 virtual std::vector<cv::KeyPoint> generateKeypointsImpl(const cv::Mat & image, const cv::Rect & roi, const cv::Mat & mask = cv::Mat()) override;
658 virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
659
660private:
661 float scaleFactor_;
662 int nLevels_;
663 int patchSize_;
664 int edgeThreshold_;
665 int fastThreshold_;
666 int fastMinThreshold_;
667
668 cv::Ptr<ORBextractor> _orb;
669 cv::Mat descriptors_;
670};
671
673class RTABMAP_CORE_EXPORT SuperPointTorch : public Feature2D
674{
675public:
676 SuperPointTorch(const ParametersMap & parameters = ParametersMap());
677 virtual ~SuperPointTorch();
678
679 virtual void parseParameters(const ParametersMap & parameters) override;
680 virtual Feature2D::Type getType() const override { return kFeatureSuperPointTorch; }
681 virtual bool isGpuAvailable() const override;
682
683private:
684 virtual std::vector<cv::KeyPoint> generateKeypointsImpl(const cv::Mat & image, const cv::Rect & roi, const cv::Mat & mask = cv::Mat()) override;
685 virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
686
687 cv::Ptr<SPDetector> superPoint_;
688
689 std::string path_;
690 float threshold_;
691 bool nms_;
692 int minDistance_;
693 bool cuda_;
694};
695
697class RTABMAP_CORE_EXPORT SuperPointRpautrat : public Feature2D
698{
699public:
700 SuperPointRpautrat(const ParametersMap & parameters = ParametersMap());
701 virtual ~SuperPointRpautrat();
702
703 virtual void parseParameters(const ParametersMap & parameters) override;
704 virtual Feature2D::Type getType() const override { return kFeatureSuperPointRpautrat; }
705 virtual bool isGpuAvailable() const override;
706
707private:
708 virtual std::vector<cv::KeyPoint> generateKeypointsImpl(const cv::Mat & image, const cv::Rect & roi, const cv::Mat & mask = cv::Mat()) override;
709 virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
710
711 cv::Ptr<SPDetectorRpautrat> superPoint_;
712
713 std::string superpointWeightsPath_;
714 std::string superpointModelPath_;
715 std::string outputDir_;
716 float threshold_;
717 bool nms_;
718 int minDistance_;
719 bool cuda_;
720};
721
723class RTABMAP_CORE_EXPORT GFTT_DAISY : public GFTT
724{
725public:
726 GFTT_DAISY(const ParametersMap & parameters = ParametersMap());
727 virtual ~GFTT_DAISY();
728
729 virtual void parseParameters(const ParametersMap & parameters) override;
730 virtual Feature2D::Type getType() const override {return kFeatureGfttDaisy;}
731
732private:
733 virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
734
735private:
736 bool orientationNormalized_;
737 bool scaleNormalized_;
738 float patternScale_;
739 int nOctaves_;
740
741#if CV_MAJOR_VERSION > 2
742 cv::Ptr<CV_DAISY> _daisy;
743#endif
744};
745
747class RTABMAP_CORE_EXPORT SURF_DAISY : public SURF
748{
749public:
750 SURF_DAISY(const ParametersMap & parameters = ParametersMap());
751 virtual ~SURF_DAISY();
752
753 virtual void parseParameters(const ParametersMap & parameters) override;
754 virtual Feature2D::Type getType() const override {return kFeatureSurfDaisy;}
755
756private:
757 virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
758
759private:
760 bool orientationNormalized_;
761 bool scaleNormalized_;
762 float patternScale_;
763 int nOctaves_;
764
765#if CV_MAJOR_VERSION > 2
766 cv::Ptr<CV_DAISY> _daisy;
767#endif
768};
769
770}
771
772#endif /* FEATURES2D_H_ */
BRISK detector and descriptor.
Definition Features2d.h:599
FAST corners + BRIEF descriptors.
Definition Features2d.h:453
FAST corners + FREAK descriptors.
Definition Features2d.h:472
FAST corner detector only (no descriptor).
Definition Features2d.h:416
virtual bool isGpuAvailable() const override
Returns true when a GPU/CUDA code path could be used by this detector on this host: i....
Abstract 2D feature detector and descriptor extractor for visual SLAM.
Definition Features2d.h:145
static void filterKeypointsByDisparity(std::vector< cv::KeyPoint > &keypoints, const cv::Mat &disparity, float minDisparity)
Keeps keypoints with stereo disparity ≥ minDisparity.
static Feature2D * create(const ParametersMap &parameters=ParametersMap())
Creates a detector from Kp/DetectorStrategy in parameters. Caller owns the pointer.
static bool isAvailable(Feature2D::Type type)
Returns true if type is available (RTAB-Map is built with it).
Type
Built-in detector/descriptor strategy (Kp/DetectorStrategy).
Definition Features2d.h:148
std::vector< cv::KeyPoint > generateKeypoints(const cv::Mat &image, const cv::Mat &mask=cv::Mat())
Detects keypoints in a grayscale image (CV_8UC1); optional depth or 8U mask.
static cv::Rect computeRoi(const cv::Mat &image, const std::string &roiRatios)
ROI from Kp/RoiRatios string ("left top right bottom" fractions).
virtual bool isGpuAvailable() const
Returns true when a GPU/CUDA code path could be used by this detector on this host: i....
Definition Features2d.h:294
static std::string typeName(Type type)
Definition Features2d.h:169
static void limitKeypoints(std::vector< cv::KeyPoint > &keypoints, int maxKeypoints, const cv::Size &imageSize=cv::Size(), bool ssc=false)
Reduces keypoint count (by response or SSC spatial distribution).
static void filterKeypointsByDepth(std::vector< cv::KeyPoint > &keypoints, const cv::Mat &depth, float minDepth, float maxDepth)
Keeps keypoints whose depth at (u,v) is in (minDepth, maxDepth).
static Feature2D * create(Feature2D::Type type, const ParametersMap &parameters=ParametersMap())
Creates a detector of the given type. Caller owns the pointer.
cv::Mat generateDescriptors(const cv::Mat &image, std::vector< cv::KeyPoint > &keypoints) const
Computes descriptors for keypoints (may shrink the list in some detectors).
std::vector< cv::Point3f > generateKeypoints3D(const SensorData &data, const std::vector< cv::KeyPoint > &keypoints) const
Back-projects keypoints to 3D using depth or stereo in data.
GFTT corners + BRIEF descriptors.
Definition Features2d.h:519
GFTT corners + DAISY descriptors (OpenCV 3+ xfeatures2d).
Definition Features2d.h:724
GFTT corners + FREAK descriptors.
Definition Features2d.h:538
GFTT corners + ORB descriptors (common default when SURF is unavailable).
Definition Features2d.h:582
Good-features-to-track detector (Shi–Tomasi / Harris).
Definition Features2d.h:494
virtual bool isGpuAvailable() const override
Returns true when a GPU/CUDA code path could be used by this detector on this host: i....
KAZE detector and descriptor (OpenCV 3+).
Definition Features2d.h:621
ORB with octree spatial distribution (RTAB-Map must be built with OCTREE enabled).
Definition Features2d.h:648
ORB detector and descriptor (optional GPU).
Definition Features2d.h:384
virtual bool isGpuAvailable() const override
Returns true when a GPU/CUDA code path could be used by this detector on this host: i....
SIFT detector and descriptor (optional GPU / CudaSift).
Definition Features2d.h:349
virtual bool isGpuAvailable() const override
Returns true when a GPU/CUDA code path could be used by this detector on this host: i....
SURF detector + DAISY descriptors (OpenCV 3+ xfeatures2d).
Definition Features2d.h:748
SURF detector + FREAK descriptors.
Definition Features2d.h:560
SURF detector and descriptor (non-free / xfeatures2d depending on OpenCV build).
Definition Features2d.h:321
virtual bool isGpuAvailable() const override
Returns true when a GPU/CUDA code path could be used by this detector on this host: i....
Container class for all sensor data captured at a specific time.
Definition SensorData.h:97
Sparse stereo matching using block matching.
Definition Stereo.h:55
SuperPoint (rpautrat) via Torch + Python (RTAB-Map must be built with libtorch and Python support).
Definition Features2d.h:698
virtual bool isGpuAvailable() const override
Returns true when a GPU/CUDA code path could be used by this detector on this host: i....
SuperPoint via LibTorch (RTAB-Map must be built with libtorch support).
Definition Features2d.h:674
virtual bool isGpuAvailable() const override
Returns true when a GPU/CUDA code path could be used by this detector on this host: i....
std::map< std::string, std::string > ParametersMap
Parameter keys mapped to their values, as used by every configurable class (see Parameters).
Definition Parameters.h:44