RTAB-Map 0.24.5
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/imgcodecs.hpp>
34#include <opencv2/videoio.hpp>
35#include <opencv2/core/core.hpp>
36#if CV_MAJOR_VERSION < 5
37#include <opencv2/features2d/features2d.hpp>
38#else
39#include <opencv2/features.hpp>
40#endif
41#include <list>
42#include <numeric>
43#include "rtabmap/core/Parameters.h"
44#include "rtabmap/core/SensorData.h"
45
46#if CV_MAJOR_VERSION < 3
47namespace cv{
48class SURF;
49class SIFT;
50namespace gpu {
51 class SURF_GPU;
52 class ORB_GPU;
53 class FAST_GPU;
54 class GoodFeaturesToTrackDetector_GPU;
55}
56}
57typedef cv::SIFT CV_SIFT;
58typedef cv::SURF CV_SURF;
59typedef cv::FastFeatureDetector CV_FAST;
60typedef cv::FREAK CV_FREAK;
61typedef cv::GFTTDetector CV_GFTT;
62typedef cv::BriefDescriptorExtractor CV_BRIEF;
63typedef cv::BRISK CV_BRISK;
64typedef cv::gpu::SURF_GPU CV_SURF_GPU;
65typedef cv::gpu::ORB_GPU CV_ORB_GPU;
66typedef cv::gpu::FAST_GPU CV_FAST_GPU;
67typedef cv::gpu::GoodFeaturesToTrackDetector_GPU CV_GFTT_GPU;
68#else
69namespace cv{
70namespace xfeatures2d {
71class FREAK;
72class DAISY;
73class BriefDescriptorExtractor;
74#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)))
75class SIFT;
76#endif
77class SURF;
78#if (CV_MAJOR_VERSION == 5)
79class BRISK;
80class KAZE;
81#endif
82}
83namespace cuda {
84class FastFeatureDetector;
85class ORB;
86class SURF_CUDA;
87class CornersDetector;
88}
89}
90#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)))
91typedef cv::xfeatures2d::SIFT CV_SIFT;
92#else
93typedef cv::SIFT CV_SIFT; // SIFT is back in features2d since 4.4.0 / 3.4.11
94#endif
95typedef cv::xfeatures2d::SURF CV_SURF;
96typedef cv::FastFeatureDetector CV_FAST;
97typedef cv::xfeatures2d::FREAK CV_FREAK;
98typedef cv::xfeatures2d::DAISY CV_DAISY;
99typedef cv::GFTTDetector CV_GFTT;
100typedef cv::xfeatures2d::BriefDescriptorExtractor CV_BRIEF;
101#if (CV_MAJOR_VERSION < 5)
102typedef cv::BRISK CV_BRISK;
103typedef cv::KAZE CV_KAZE;
104#else
105typedef cv::xfeatures2d::BRISK CV_BRISK;
106typedef cv::xfeatures2d::KAZE CV_KAZE;
107#endif
108typedef cv::ORB CV_ORB;
109typedef cv::cuda::SURF_CUDA CV_SURF_GPU;
110typedef cv::cuda::ORB CV_ORB_GPU;
111typedef cv::cuda::FastFeatureDetector CV_FAST_GPU;
112typedef cv::cuda::CornersDetector CV_GFTT_GPU;
113#endif
114
115// CudaSift fork: https://github.com/matlabbe/CudaSift
116class SiftData;
117
118namespace rtabmap {
119
120class ORBextractor;
121class SPDetector;
122class SPDetectorRpautrat;
123
124class Stereo;
125#if CV_MAJOR_VERSION < 3
126class CV_ORB;
127#endif
128
146class RTABMAP_CORE_EXPORT Feature2D {
147public:
149 enum Type {kFeatureUndef=-1,
150 kFeatureSurf=0,
151 kFeatureSift=1,
152 kFeatureOrb=2,
153 kFeatureFastFreak=3,
154 kFeatureFastBrief=4,
155 kFeatureGfttFreak=5,
156 kFeatureGfttBrief=6,
157 kFeatureBrisk=7,
158 kFeatureGfttOrb=8, //new 0.10.11
159 kFeatureKaze=9, //new 0.13.2
160 kFeatureOrbOctree=10, //new 0.19.2
161 kFeatureSuperPointTorch=11, //new 0.19.7
162 kFeatureSurfFreak=12, //new 0.20.4
163 kFeatureGfttDaisy=13, //new 0.20.6
164 kFeatureSurfDaisy=14, //new 0.20.6
165 kFeaturePyDetector=15, //new 0.20.8
166 kFeatureSuperPointRpautrat=16, // new 0.23.3
167 kFeatureOnnxDetector=17, // new 0.24.3
168 kFeatureEnd}; // Sentinel: always keep last. Used to iterate through types.
169
171 static std::string typeName(Type type)
172 {
173 switch(type){
174 case kFeatureSurf:
175 return "SURF";
176 case kFeatureSift:
177 return "SIFT";
178 case kFeatureOrb:
179 return "ORB";
180 case kFeatureFastFreak:
181 return "FAST+FREAK";
182 case kFeatureFastBrief:
183 return "FAST+BRIEF";
184 case kFeatureGfttFreak:
185 return "GFTT+Freak";
186 case kFeatureGfttBrief:
187 return "GFTT+Brief";
188 case kFeatureBrisk:
189 return "BRISK";
190 case kFeatureGfttOrb:
191 return "GFTT+ORB";
192 case kFeatureKaze:
193 return "KAZE";
194 case kFeatureOrbOctree:
195 return "ORB-OCTREE";
196 case kFeatureSuperPointTorch:
197 return "SUPERPOINT";
198 case kFeatureSurfFreak:
199 return "SURF+Freak";
200 case kFeatureGfttDaisy:
201 return "GFTT+Daisy";
202 case kFeatureSurfDaisy:
203 return "SURF+Daisy";
204 case kFeaturePyDetector:
205 return "PyDetector";
206 case kFeatureSuperPointRpautrat:
207 return "SUPERPOINT-RPAUTRAT";
208 case kFeatureOnnxDetector:
209 return "OnnxDetector";
210 default:
211 return "Unknown";
212 }
213 }
214
216 static Feature2D * create(const ParametersMap & parameters = ParametersMap());
218 static Feature2D * create(Feature2D::Type type, const ParametersMap & parameters = ParametersMap());
219
221 static bool isAvailable(Feature2D::Type type);
222
225 std::vector<cv::KeyPoint> & keypoints,
226 const cv::Mat & depth,
227 float minDepth,
228 float maxDepth);
229 static void filterKeypointsByDepth(
230 std::vector<cv::KeyPoint> & keypoints,
231 cv::Mat & descriptors,
232 const cv::Mat & depth,
233 float minDepth,
234 float maxDepth);
235 static void filterKeypointsByDepth(
236 std::vector<cv::KeyPoint> & keypoints,
237 cv::Mat & descriptors,
238 std::vector<cv::Point3f> & keypoints3D,
239 float minDepth,
240 float maxDepth);
241
244 std::vector<cv::KeyPoint> & keypoints,
245 const cv::Mat & disparity,
246 float minDisparity);
247 static void filterKeypointsByDisparity(
248 std::vector<cv::KeyPoint> & keypoints,
249 cv::Mat & descriptors,
250 const cv::Mat & disparity,
251 float minDisparity);
252
254 static void limitKeypoints(std::vector<cv::KeyPoint> & keypoints, int maxKeypoints, const cv::Size & imageSize = cv::Size(), bool ssc = false);
255 static void limitKeypoints(std::vector<cv::KeyPoint> & keypoints, cv::Mat & descriptors, int maxKeypoints, const cv::Size & imageSize = cv::Size(), bool ssc = false);
256 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);
257 static void limitKeypoints(const std::vector<cv::KeyPoint> & keypoints, std::vector<bool> & inliers, int maxKeypoints, const cv::Size & imageSize = cv::Size(), bool ssc = false);
258 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);
259
261 static cv::Rect computeRoi(const cv::Mat & image, const std::string & roiRatios);
262 static cv::Rect computeRoi(const cv::Mat & image, const std::vector<float> & roiRatios);
263
264 int getMaxFeatures() const {return maxFeatures_;}
265 bool getSSC() const {return SSC_;}
266 float getMinDepth() const {return _minDepth;}
267 float getMaxDepth() const {return _maxDepth;}
268 int getGridRows() const {return gridRows_;}
269 int getGridCols() const {return gridCols_;}
270
271public:
272 virtual ~Feature2D();
273
275 std::vector<cv::KeyPoint> generateKeypoints(
276 const cv::Mat & image,
277 const cv::Mat & mask = cv::Mat());
280 const cv::Mat & image,
281 std::vector<cv::KeyPoint> & keypoints) const;
283 std::vector<cv::Point3f> generateKeypoints3D(
284 const SensorData & data,
285 const std::vector<cv::KeyPoint> & keypoints) const;
286
287 virtual void parseParameters(const ParametersMap & parameters);
288 virtual const ParametersMap & getParameters() const {return parameters_;}
289 virtual Feature2D::Type getType() const = 0;
290
298 virtual bool isGpuAvailable() const {return false;}
299
300protected:
301 Feature2D(const ParametersMap & parameters = ParametersMap());
302
303private:
304 virtual std::vector<cv::KeyPoint> generateKeypointsImpl(const cv::Mat & image, const cv::Rect & roi, const cv::Mat & mask = cv::Mat()) = 0;
305 virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const = 0;
306
307private:
308 ParametersMap parameters_;
309 int maxFeatures_;
310 bool SSC_;
311 float _maxDepth; // 0=inf
312 float _minDepth;
313 std::vector<float> _roiRatios; // size 4
314 int _subPixWinSize;
315 int _subPixIterations;
316 double _subPixEps;
317 int gridRows_;
318 int gridCols_;
319 // Stereo stuff
320 Stereo * _stereo;
321};
322
324class RTABMAP_CORE_EXPORT SURF : public Feature2D
325{
326public:
327 SURF(const ParametersMap & parameters = ParametersMap());
328 virtual ~SURF();
329
330 virtual void parseParameters(const ParametersMap & parameters) override;
331 virtual Feature2D::Type getType() const override {return kFeatureSurf;}
332 virtual bool isGpuAvailable() const override;
333
334private:
335 virtual std::vector<cv::KeyPoint> generateKeypointsImpl(const cv::Mat & image, const cv::Rect & roi, const cv::Mat & mask = cv::Mat()) override;
336 virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
337
338private:
339 double hessianThreshold_;
340 int nOctaves_;
341 int nOctaveLayers_;
342 bool extended_;
343 bool upright_;
344 float gpuKeypointsRatio_;
345 bool gpuVersion_;
346
347 cv::Ptr<CV_SURF> _surf;
348 cv::Ptr<CV_SURF_GPU> _gpuSurf;
349};
350
352class RTABMAP_CORE_EXPORT SIFT : public Feature2D
353{
354public:
355 SIFT(const ParametersMap & parameters = ParametersMap());
356 virtual ~SIFT();
357
358 virtual void parseParameters(const ParametersMap & parameters) override;
359 virtual Feature2D::Type getType() const override {return kFeatureSift;}
360 virtual bool isGpuAvailable() const override;
361
362private:
363 virtual std::vector<cv::KeyPoint> generateKeypointsImpl(const cv::Mat & image, const cv::Rect & roi, const cv::Mat & mask = cv::Mat()) override;
364 virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
365
366private:
367 int nOctaveLayers_;
368 double contrastThreshold_;
369 double edgeThreshold_;
370 double sigma_;
371 bool preciseUpscale_;
372 bool rootSIFT_;
373 bool gpu_;
374 float gaussianThreshold_;
375 float maxGaussianThreshold_;
376 bool upscale_;
377
378 cv::Ptr<CV_SIFT> sift_;
379 SiftData * cudaSiftData_;
380 float * cudaSiftMemory_;
381 cv::Size cudaSiftMemorySize_;
382 cv::Mat cudaSiftDescriptors_;
383 bool cudaSiftUpscaling_;
384};
385
387class RTABMAP_CORE_EXPORT ORB : public Feature2D
388{
389public:
390 ORB(const ParametersMap & parameters = ParametersMap());
391 virtual ~ORB();
392
393 virtual void parseParameters(const ParametersMap & parameters) override;
394 virtual Feature2D::Type getType() const override {return kFeatureOrb;}
395 virtual bool isGpuAvailable() const override;
396
397private:
398 virtual std::vector<cv::KeyPoint> generateKeypointsImpl(const cv::Mat & image, const cv::Rect & roi, const cv::Mat & mask = cv::Mat()) override;
399 virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
400
401private:
402 float scaleFactor_;
403 int nLevels_;
404 int edgeThreshold_;
405 int firstLevel_;
406 int WTA_K_;
407 int scoreType_;
408 int patchSize_;
409 bool gpu_;
410
411 int fastThreshold_;
412 bool nonmaxSuppresion_;
413
414 cv::Ptr<CV_ORB> _orb;
415 cv::Ptr<CV_ORB_GPU> _gpuOrb;
416};
417
419class RTABMAP_CORE_EXPORT FAST : public Feature2D
420{
421public:
422 FAST(const ParametersMap & parameters = ParametersMap());
423 virtual ~FAST();
424
425 virtual void parseParameters(const ParametersMap & parameters) override;
426 virtual Feature2D::Type getType() const override {return kFeatureUndef;}
427 virtual bool isGpuAvailable() const override;
428
429private:
430 virtual std::vector<cv::KeyPoint> generateKeypointsImpl(const cv::Mat & image, const cv::Rect & roi, const cv::Mat & mask = cv::Mat()) override;
431 virtual cv::Mat generateDescriptorsImpl(const cv::Mat &, std::vector<cv::KeyPoint> &) const override {return cv::Mat();}
432
433private:
434 int threshold_;
435 bool nonmaxSuppression_;
436 bool gpu_;
437 double gpuKeypointsRatio_;
438 int minThreshold_;
439 int maxThreshold_;
440 int gridRows_;
441 int gridCols_;
442 int fastCV_;
443
444 bool fastCVinit_;
445 int fastCVMaxFeatures_;
446 int fastCVLastImageHeight_;
447 uint32_t* fastCVCorners_= NULL;
448 uint32_t* fastCVCornerScores_ = NULL;
449 void* fastCVTempBuf_ = NULL;
450
451 cv::Ptr<cv::FeatureDetector> _fast;
452 cv::Ptr<CV_FAST_GPU> _gpuFast;
453};
454
456class RTABMAP_CORE_EXPORT FAST_BRIEF : public FAST
457{
458public:
459 FAST_BRIEF(const ParametersMap & parameters = ParametersMap());
460 virtual ~FAST_BRIEF();
461
462 virtual void parseParameters(const ParametersMap & parameters) override;
463 virtual Feature2D::Type getType() const override {return kFeatureFastBrief;}
464
465private:
466 virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
467
468private:
469 int bytes_;
470
471 cv::Ptr<CV_BRIEF> _brief;
472};
473
475class RTABMAP_CORE_EXPORT FAST_FREAK : public FAST
476{
477public:
478 FAST_FREAK(const ParametersMap & parameters = ParametersMap());
479 virtual ~FAST_FREAK();
480
481 virtual void parseParameters(const ParametersMap & parameters) override;
482 virtual Feature2D::Type getType() const override {return kFeatureFastFreak;}
483
484private:
485 virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
486
487private:
488 bool orientationNormalized_;
489 bool scaleNormalized_;
490 float patternScale_;
491 int nOctaves_;
492
493 cv::Ptr<CV_FREAK> _freak;
494};
495
497class RTABMAP_CORE_EXPORT GFTT : public Feature2D
498{
499public:
500 GFTT(const ParametersMap & parameters = ParametersMap());
501 virtual ~GFTT();
502
503 virtual void parseParameters(const ParametersMap & parameters) override;
504 virtual bool isGpuAvailable() const override;
505
506private:
507 virtual std::vector<cv::KeyPoint> generateKeypointsImpl(const cv::Mat & image, const cv::Rect & roi, const cv::Mat & mask = cv::Mat()) override;
508
509private:
510 double _qualityLevel;
511 double _minDistance;
512 int _blockSize;
513 bool _useHarrisDetector;
514 double _k;
515 bool _gpu;
516
517 cv::Ptr<CV_GFTT> _gftt;
518 cv::Ptr<CV_GFTT_GPU> _gpuGftt;
519};
520
522class RTABMAP_CORE_EXPORT GFTT_BRIEF : public GFTT
523{
524public:
525 GFTT_BRIEF(const ParametersMap & parameters = ParametersMap());
526 virtual ~GFTT_BRIEF();
527
528 virtual void parseParameters(const ParametersMap & parameters) override;
529 virtual Feature2D::Type getType() const override {return kFeatureGfttBrief;}
530
531private:
532 virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
533
534private:
535 int bytes_;
536
537 cv::Ptr<CV_BRIEF> _brief;
538};
539
541class RTABMAP_CORE_EXPORT GFTT_FREAK : public GFTT
542{
543public:
544 GFTT_FREAK(const ParametersMap & parameters = ParametersMap());
545 virtual ~GFTT_FREAK();
546
547 virtual void parseParameters(const ParametersMap & parameters) override;
548 virtual Feature2D::Type getType() const override {return kFeatureGfttFreak;}
549
550private:
551 virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
552
553private:
554 bool orientationNormalized_;
555 bool scaleNormalized_;
556 float patternScale_;
557 int nOctaves_;
558
559 cv::Ptr<CV_FREAK> _freak;
560};
561
563class RTABMAP_CORE_EXPORT SURF_FREAK : public SURF
564{
565public:
566 SURF_FREAK(const ParametersMap & parameters = ParametersMap());
567 virtual ~SURF_FREAK();
568
569 virtual void parseParameters(const ParametersMap & parameters) override;
570 virtual Feature2D::Type getType() const override {return kFeatureSurfFreak;}
571
572private:
573 virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
574
575private:
576 bool orientationNormalized_;
577 bool scaleNormalized_;
578 float patternScale_;
579 int nOctaves_;
580
581 cv::Ptr<CV_FREAK> _freak;
582};
583
585class RTABMAP_CORE_EXPORT GFTT_ORB : public GFTT
586{
587public:
588 GFTT_ORB(const ParametersMap & parameters = ParametersMap());
589 virtual ~GFTT_ORB();
590
591 virtual void parseParameters(const ParametersMap & parameters) override;
592 virtual Feature2D::Type getType() const override {return kFeatureGfttOrb;}
593
594private:
595 virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
596
597private:
598 ORB _orb;
599};
600
602class RTABMAP_CORE_EXPORT BRISK : public Feature2D
603{
604public:
605 BRISK(const ParametersMap & parameters = ParametersMap());
606 virtual ~BRISK();
607
608 virtual void parseParameters(const ParametersMap & parameters) override;
609 virtual Feature2D::Type getType() const override {return kFeatureBrisk;}
610
611private:
612 virtual std::vector<cv::KeyPoint> generateKeypointsImpl(const cv::Mat & image, const cv::Rect & roi, const cv::Mat & mask = cv::Mat()) override;
613 virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
614
615private:
616 int thresh_;
617 int octaves_;
618 float patternScale_;
619
620 cv::Ptr<CV_BRISK> brisk_;
621};
622
624class RTABMAP_CORE_EXPORT KAZE : public Feature2D
625{
626public:
627 KAZE(const ParametersMap & parameters = ParametersMap());
628 virtual ~KAZE();
629
630 virtual void parseParameters(const ParametersMap & parameters) override;
631 virtual Feature2D::Type getType() const override { return kFeatureKaze; }
632
633private:
634 virtual std::vector<cv::KeyPoint> generateKeypointsImpl(const cv::Mat & image, const cv::Rect & roi, const cv::Mat & mask = cv::Mat()) override;
635 virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
636
637private:
638 bool extended_;
639 bool upright_;
640 float threshold_;
641 int nOctaves_;
642 int nOctaveLayers_;
643 int diffusivity_;
644
645#if CV_MAJOR_VERSION > 2
646 cv::Ptr<CV_KAZE> kaze_;
647#endif
648};
649
651class RTABMAP_CORE_EXPORT ORBOctree : public Feature2D
652{
653public:
654 ORBOctree(const ParametersMap & parameters = ParametersMap());
655 virtual ~ORBOctree();
656
657 virtual void parseParameters(const ParametersMap & parameters) override;
658 virtual Feature2D::Type getType() const override {return kFeatureOrbOctree;}
659
660private:
661 virtual std::vector<cv::KeyPoint> generateKeypointsImpl(const cv::Mat & image, const cv::Rect & roi, const cv::Mat & mask = cv::Mat()) override;
662 virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
663
664private:
665 float scaleFactor_;
666 int nLevels_;
667 int patchSize_;
668 int edgeThreshold_;
669 int fastThreshold_;
670 int fastMinThreshold_;
671
672 cv::Ptr<ORBextractor> _orb;
673 cv::Mat descriptors_;
674};
675
677class RTABMAP_CORE_EXPORT SuperPointTorch : public Feature2D
678{
679public:
680 SuperPointTorch(const ParametersMap & parameters = ParametersMap());
681 virtual ~SuperPointTorch();
682
683 virtual void parseParameters(const ParametersMap & parameters) override;
684 virtual Feature2D::Type getType() const override { return kFeatureSuperPointTorch; }
685 virtual bool isGpuAvailable() const override;
686
687private:
688 virtual std::vector<cv::KeyPoint> generateKeypointsImpl(const cv::Mat & image, const cv::Rect & roi, const cv::Mat & mask = cv::Mat()) override;
689 virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
690
691 cv::Ptr<SPDetector> superPoint_;
692
693 std::string path_;
694 float threshold_;
695 bool nms_;
696 int minDistance_;
697 bool cuda_;
698};
699
701class RTABMAP_CORE_EXPORT SuperPointRpautrat : public Feature2D
702{
703public:
704 SuperPointRpautrat(const ParametersMap & parameters = ParametersMap());
705 virtual ~SuperPointRpautrat();
706
707 virtual void parseParameters(const ParametersMap & parameters) override;
708 virtual Feature2D::Type getType() const override { return kFeatureSuperPointRpautrat; }
709 virtual bool isGpuAvailable() const override;
710
711private:
712 virtual std::vector<cv::KeyPoint> generateKeypointsImpl(const cv::Mat & image, const cv::Rect & roi, const cv::Mat & mask = cv::Mat()) override;
713 virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
714
715 cv::Ptr<SPDetectorRpautrat> superPoint_;
716
717 std::string superpointWeightsPath_;
718 std::string superpointModelPath_;
719 std::string outputDir_;
720 float threshold_;
721 bool nms_;
722 int minDistance_;
723 bool cuda_;
724};
725
727class RTABMAP_CORE_EXPORT GFTT_DAISY : public GFTT
728{
729public:
730 GFTT_DAISY(const ParametersMap & parameters = ParametersMap());
731 virtual ~GFTT_DAISY();
732
733 virtual void parseParameters(const ParametersMap & parameters) override;
734 virtual Feature2D::Type getType() const override {return kFeatureGfttDaisy;}
735
736private:
737 virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
738
739private:
740 bool orientationNormalized_;
741 bool scaleNormalized_;
742 float patternScale_;
743 int nOctaves_;
744
745#if CV_MAJOR_VERSION > 2
746 cv::Ptr<CV_DAISY> _daisy;
747#endif
748};
749
751class RTABMAP_CORE_EXPORT SURF_DAISY : public SURF
752{
753public:
754 SURF_DAISY(const ParametersMap & parameters = ParametersMap());
755 virtual ~SURF_DAISY();
756
757 virtual void parseParameters(const ParametersMap & parameters) override;
758 virtual Feature2D::Type getType() const override {return kFeatureSurfDaisy;}
759
760private:
761 virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
762
763private:
764 bool orientationNormalized_;
765 bool scaleNormalized_;
766 float patternScale_;
767 int nOctaves_;
768
769#if CV_MAJOR_VERSION > 2
770 cv::Ptr<CV_DAISY> _daisy;
771#endif
772};
773
774}
775
776#endif /* FEATURES2D_H_ */
BRISK detector and descriptor.
Definition Features2d.h:603
FAST corners + BRIEF descriptors.
Definition Features2d.h:457
FAST corners + FREAK descriptors.
Definition Features2d.h:476
FAST corner detector only (no descriptor).
Definition Features2d.h:420
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:146
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:149
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:298
static std::string typeName(Type type)
Definition Features2d.h:171
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:523
GFTT corners + DAISY descriptors (OpenCV 3+ xfeatures2d).
Definition Features2d.h:728
GFTT corners + FREAK descriptors.
Definition Features2d.h:542
GFTT corners + ORB descriptors (common default when SURF is unavailable).
Definition Features2d.h:586
Good-features-to-track detector (Shi–Tomasi / Harris).
Definition Features2d.h:498
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:625
ORB with octree spatial distribution (RTAB-Map must be built with OCTREE enabled).
Definition Features2d.h:652
ORB detector and descriptor (optional GPU).
Definition Features2d.h:388
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:353
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:752
SURF detector + FREAK descriptors.
Definition Features2d.h:564
SURF detector and descriptor (non-free / xfeatures2d depending on OpenCV build).
Definition Features2d.h:325
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:702
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:678
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