mirror of
https://github.com/introlab/rtabmap.git
synced 2026-10-04 00:57:46 +08:00
* added doc and tests for util2d.h * updated cmake-ros ci * Added util3d.h doc and tests * util3d_transforms.h: Added doc and tests * util3d_filtering.h: started doc and test * util3d_filtering.h: more tests and doc * Added more doc/tests * finished util3d_filtering doc and tests * added test for util2d::depthBleedingFiltering * Added util3d_registration tests * Added util3d_features.h doc/tests * added doc/tests for util3d_correspondences.h * added doc/gtest for util3d_mapping.h (missing hpp functions) * finished testing util3d_mapping.hpp * Added util3d_motion_estimation.h tests (2D->3D done) * finished util3d_motion_estimation.h tests * minimal util3d_surface.h * Added Transform and VisualWord tests * Added doc for CameraModel and StereoCameraModel * Added more logs in ros ci * Passing tests on fical * improved all devcontainer * added devcontainer kilted, fixed source setup.bash, removed ldconfig in ros-cmake workflow * cleanup * source ros * Added utilite tests * Added testing to appveyor, github actions cancellable on re-commit on same branch * appveyor testing without all targets * appveyor: specifying ALL_BUILD target * Fixed Util2dTest.NMSImageBoundsRespected test * Fixing PCL Indices error on old pcl * Added VWDictionary tests and doc. Fixed LSH not working (fix from https://github.com/flann-lib/flann/pull/472 * fixing some appveyor CI errors, added test to check dictionary serialization against all type * Added StereoDense, StereoBM and StereoSGBM doc and tests * Added Stereo tests * Added CameraModel and StereoCameraModel tests * Added doc and test for Statistics * Added doc/tests for Signature * Added doc/test for SensorEvent, added doc for SensorCaptureInfo * Added doc to SensorData * Added SensorData tests * Added SensorCapture and SensorCaptureThread doc and tests * fixed sensordata test * updated SSC test and doc * Added doc and tests for BayesFilter class * Enabled testing on mac, updated windows testing like on linux * added test_link * fixed unresolved on windows * fixed ThreadHandle error on macos ci * Added GPS and GeodeticCoords tests * Added tests for compression * Added Odometry tests (base class only) * Added DBDriver tests * Added coverage report * uniformized test names * fixing concurancy and coverage ci * dont built tools, examples and app for coverage build * fixed report tool rebuilt without qt compilation error * updated coverage option * updated coverage config * added doc CI job * fixing windows and mac ci errors * Added DBDriverSqlite3 tests * Added IMU tests * Added Graph tests * fixing flaky macos test * Added IMUThread and IMUFilter tests * Added Landmarks tests * Added LASWriter tests * fixing seed flaky test * fixing flaky macos timing tests * Added LocalGrid tests * Added LocalGridMaker tests * fixing ci errors * Added GlobalMap tests * Added doc for EnvSensor * Added Features2D tests * Added Registration tests * Added RegistrationVis tests * Added doc for Rtabmap and Memory classes * Added Memory and Rtabmap tests * making some tests less flaky * lcov 1.14 support * updated compatible tool arguments * Added integration tests (RGB-D, Stereo, Lidar2d, Lidar3d) * More octomap checks * Refactored how/when python interpretor is created to simplify library usage * Added python tests * fixed some flaky tests * suppressed some third party related warnings * fixed ceres tests * more flaky fixes * Fixing tests without libpointmatcher * Added RANSAC rejection filter to PCL ICP * fixing multi platform flakiness * Added test to detect regression * Fixing windows pcl link error * fixed some macos flakiness * bigger 2D2D registration error on opencv 4.6.0 * flakiness * fixing flaky tests on windows and mac * flaky thread test on slow mac VM * windows slow test * fixing more ci erros * fxing temp dir on windows * Added Optimizer tests and discovered some bugs (fixed) * fixing flaky tests in mac and windows * Added Optimizer doc * Added GTSAM BA, updated Ceres to use g2o ba parameters. Renamed g2o's ba related parameters to Optimizer group and used by both gtsam and ceres. * fixing build without gtsam * fixing home dir * fixing python ci isssues * Added multicam ba tests * Added Ceres multicam BA support * Aligned BundleAdjustment parameters with Optimizer/Strategy to avoid confusion in the code * Added BA integration test * Added robust graph optimization integration test * Added loop3it test * Added stereo20Hz test * Added smartfactor gtsam * Fixed bugged check and warn if python didn't return any descriptors * Fixing gtsam version build issues * fixing tilt on windows ci * loosing ceres integration test for ci * mac ci flakiness * updating missing param in gui * updating test bound for mac * added appearance-based tests, set min gftt quality to quality level * testing more stuff * improving features2d tests * ci flakiness * fixing flaky ci * ci fixes * flaky fixes * Added RegistrationIcp tests * Added icp integration test with real-worl corridor like env * intermediate nodes * fixing enum * Updated test to catch #1714 * Fixed 2d corridor failing on pcl * flaky pnp test * flaky brisk test * Set rtabmap_integration test as long * updating loop closure test * flaky ci tests * TEsting roundtrip g2o/toro save/load * loosing test bound * fixed cuda capable checks * flaky tests * Debugging test hanging * more debugging stuff * updating limit * windows: disabled cuda on ci to avoid incompatible driver issue. Fixing a bad test mem allocation * trying fixing cuda hanging issue * fixing ci flakyness * flaky tests * Updated BOW flaky tests by checking min precision/recall instead of recall@100precision. Fixed signature test * CameraModel::load() test initRectificationMap param * test dbdriver load dictionary idsOnly * Memory: test keepLinkedInDb param * added dummyDictionary tests * test intermediate nodes count * Added MarkerDetector tests * reverted breaking change of UMutex and USemaphore * Features2d: fixed compiltion warnings with clang about override * clang warnings * fixing test build with pcl 1.8 * g2o and gtsam build errors on android * opencv5 test fixes * disabled testing for ios and android builds * normalized endline characters for easier diff * added LF CRLF rule * bump 0.23.10. fixing doc version * Publish rtabmap website doc from ci * fixing MSCVC build error * macos icp flaky test * fixing ceres macos test bound * ficing more flaky tests * fixing opencv5 related test errors. Also fixed an actual bug in ENU_WGS84ToGeocentric_WGS84() * added comment about mrpt change * removed rosdoc2 (will add it for rtabmap_ros later) * fixing website style * updated download links * locally deployable website with api * sweep doxygen issues * improved/revised doxygen main pages * removed examples empty page * Updated doxygen style * more concise doxygen groups * added api link on main readme * fixing utilite test error * fixing CommonFilteringGroundNormalsUp test * updated precisionRecall test bounds for Freak and brief descriptors * fixing scale check in ba tests * disabled tests on windows cuda build (missing dlls amd runner cannot test cuda anyway) * ceres: missing suitesparse dep in windows ci * adjusting recall thr for fast/freak * ficing more flaky tests * fixing flaky tests * disabled coverage in ros ci * Enable integration tests for ros ci jobs * loosing up some threshold for failing tests * trigger cache * fixing test data in ros ci. Updated flaky test for mac * slaking some test limit * Fixed rtabmap-detectMoreLoopClosures inverted output value * loosing up sift recall on mac * optimizer re-ordered distribution for reproducible results (mac g2o) * macos dump test crash log * combining all tests to save time on shared library reload. Also fixed Logs with missing arguments. * Added ENABLE_FORMAT_ERRORS cmake option * do test only one time * fixed all format warnings * format security android build errors * less verbose tests * updated ImuUThread test * fixed a log * Fixed libpointmatcher 2d normals eigen issue * Fixing libpointmatcher conversion issues * fixing libpointmatcher test on windows ci * cleanup comments, relax some test thr * disabled sequoia-intel ci build (too flaky, would need extensive testing directly on that machine)
773 lines
26 KiB
C++
773 lines
26 KiB
C++
/*
|
||
Copyright (c) 2010-2016, Mathieu Labbe - IntRoLab - Universite de Sherbrooke
|
||
All rights reserved.
|
||
|
||
Redistribution and use in source and binary forms, with or without
|
||
modification, are permitted provided that the following conditions are met:
|
||
* Redistributions of source code must retain the above copyright
|
||
notice, this list of conditions and the following disclaimer.
|
||
* Redistributions in binary form must reproduce the above copyright
|
||
notice, this list of conditions and the following disclaimer in the
|
||
documentation and/or other materials provided with the distribution.
|
||
* Neither the name of the Universite de Sherbrooke nor the
|
||
names of its contributors may be used to endorse or promote products
|
||
derived from this software without specific prior written permission.
|
||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
|
||
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||
*/
|
||
|
||
#ifndef FEATURES2D_H_
|
||
#define FEATURES2D_H_
|
||
|
||
#include "rtabmap/core/rtabmap_core_export.h" // DLL export/import defines
|
||
|
||
#include <opencv2/highgui/highgui.hpp>
|
||
#include <opencv2/core/core.hpp>
|
||
#if CV_MAJOR_VERSION < 5
|
||
#include <opencv2/features2d/features2d.hpp>
|
||
#else
|
||
#include <opencv2/features.hpp>
|
||
#endif
|
||
#include <list>
|
||
#include <numeric>
|
||
#include "rtabmap/core/Parameters.h"
|
||
#include "rtabmap/core/SensorData.h"
|
||
|
||
#if CV_MAJOR_VERSION < 3
|
||
namespace cv{
|
||
class SURF;
|
||
class SIFT;
|
||
namespace gpu {
|
||
class SURF_GPU;
|
||
class ORB_GPU;
|
||
class FAST_GPU;
|
||
class GoodFeaturesToTrackDetector_GPU;
|
||
}
|
||
}
|
||
typedef cv::SIFT CV_SIFT;
|
||
typedef cv::SURF CV_SURF;
|
||
typedef cv::FastFeatureDetector CV_FAST;
|
||
typedef cv::FREAK CV_FREAK;
|
||
typedef cv::GFTTDetector CV_GFTT;
|
||
typedef cv::BriefDescriptorExtractor CV_BRIEF;
|
||
typedef cv::BRISK CV_BRISK;
|
||
typedef cv::gpu::SURF_GPU CV_SURF_GPU;
|
||
typedef cv::gpu::ORB_GPU CV_ORB_GPU;
|
||
typedef cv::gpu::FAST_GPU CV_FAST_GPU;
|
||
typedef cv::gpu::GoodFeaturesToTrackDetector_GPU CV_GFTT_GPU;
|
||
#else
|
||
namespace cv{
|
||
namespace xfeatures2d {
|
||
class FREAK;
|
||
class DAISY;
|
||
class BriefDescriptorExtractor;
|
||
#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)))
|
||
class SIFT;
|
||
#endif
|
||
class SURF;
|
||
#if (CV_MAJOR_VERSION == 5)
|
||
class BRISK;
|
||
class KAZE;
|
||
#endif
|
||
}
|
||
namespace cuda {
|
||
class FastFeatureDetector;
|
||
class ORB;
|
||
class SURF_CUDA;
|
||
class CornersDetector;
|
||
}
|
||
}
|
||
#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)))
|
||
typedef cv::xfeatures2d::SIFT CV_SIFT;
|
||
#else
|
||
typedef cv::SIFT CV_SIFT; // SIFT is back in features2d since 4.4.0 / 3.4.11
|
||
#endif
|
||
typedef cv::xfeatures2d::SURF CV_SURF;
|
||
typedef cv::FastFeatureDetector CV_FAST;
|
||
typedef cv::xfeatures2d::FREAK CV_FREAK;
|
||
typedef cv::xfeatures2d::DAISY CV_DAISY;
|
||
typedef cv::GFTTDetector CV_GFTT;
|
||
typedef cv::xfeatures2d::BriefDescriptorExtractor CV_BRIEF;
|
||
#if (CV_MAJOR_VERSION < 5)
|
||
typedef cv::BRISK CV_BRISK;
|
||
typedef cv::KAZE CV_KAZE;
|
||
#else
|
||
typedef cv::xfeatures2d::BRISK CV_BRISK;
|
||
typedef cv::xfeatures2d::KAZE CV_KAZE;
|
||
#endif
|
||
typedef cv::ORB CV_ORB;
|
||
typedef cv::cuda::SURF_CUDA CV_SURF_GPU;
|
||
typedef cv::cuda::ORB CV_ORB_GPU;
|
||
typedef cv::cuda::FastFeatureDetector CV_FAST_GPU;
|
||
typedef cv::cuda::CornersDetector CV_GFTT_GPU;
|
||
#endif
|
||
|
||
// CudaSift fork: https://github.com/matlabbe/CudaSift
|
||
class SiftData;
|
||
|
||
namespace rtabmap {
|
||
|
||
class ORBextractor;
|
||
class SPDetector;
|
||
class SPDetectorRpautrat;
|
||
|
||
class Stereo;
|
||
#if CV_MAJOR_VERSION < 3
|
||
class CV_ORB;
|
||
#endif
|
||
|
||
/**
|
||
* @class Feature2D
|
||
* @brief Abstract 2D feature detector and descriptor extractor for visual SLAM.
|
||
*
|
||
* Factory @ref create() builds a concrete detector from @ref Type or from
|
||
* **Kp/DetectorStrategy** in a @ref ParametersMap. Common tuning keys include
|
||
* **Kp/MaxFeatures**, **Kp/GridRows**, **Kp/GridCols**, **Kp/SSC**, depth filters
|
||
* (**Kp/MinDepth**, **Kp/MaxDepth**), ROI (**Kp/RoiRatios**), and sub-pixel refinement.
|
||
*
|
||
* Pipeline: @ref generateKeypoints() (grid + ROI + optional mask) then
|
||
* @ref generateDescriptors(). Static helpers filter or cap keypoints before/after
|
||
* matching. @ref generateKeypoints3D() projects features using stereo or depth when
|
||
* available in @ref SensorData.
|
||
*
|
||
* @see Memory
|
||
* @see RegistrationVis
|
||
*/
|
||
class RTABMAP_CORE_EXPORT Feature2D {
|
||
public:
|
||
/** @brief Built-in detector/descriptor strategy (Kp/DetectorStrategy). */
|
||
enum Type {kFeatureUndef=-1,
|
||
kFeatureSurf=0,
|
||
kFeatureSift=1,
|
||
kFeatureOrb=2,
|
||
kFeatureFastFreak=3,
|
||
kFeatureFastBrief=4,
|
||
kFeatureGfttFreak=5,
|
||
kFeatureGfttBrief=6,
|
||
kFeatureBrisk=7,
|
||
kFeatureGfttOrb=8, //new 0.10.11
|
||
kFeatureKaze=9, //new 0.13.2
|
||
kFeatureOrbOctree=10, //new 0.19.2
|
||
kFeatureSuperPointTorch=11, //new 0.19.7
|
||
kFeatureSurfFreak=12, //new 0.20.4
|
||
kFeatureGfttDaisy=13, //new 0.20.6
|
||
kFeatureSurfDaisy=14, //new 0.20.6
|
||
kFeaturePyDetector=15, //new 0.20.8
|
||
kFeatureSuperPointRpautrat=16, // new 0.23.3
|
||
kFeatureEnd}; // Sentinel: always keep last. Used to iterate through types.
|
||
|
||
/** @return Human-readable name for @p type (e.g. `"ORB"`, `"GFTT+BRIEF"`). */
|
||
static std::string typeName(Type type)
|
||
{
|
||
switch(type){
|
||
case kFeatureSurf:
|
||
return "SURF";
|
||
case kFeatureSift:
|
||
return "SIFT";
|
||
case kFeatureOrb:
|
||
return "ORB";
|
||
case kFeatureFastFreak:
|
||
return "FAST+FREAK";
|
||
case kFeatureFastBrief:
|
||
return "FAST+BRIEF";
|
||
case kFeatureGfttFreak:
|
||
return "GFTT+Freak";
|
||
case kFeatureGfttBrief:
|
||
return "GFTT+Brief";
|
||
case kFeatureBrisk:
|
||
return "BRISK";
|
||
case kFeatureGfttOrb:
|
||
return "GFTT+ORB";
|
||
case kFeatureKaze:
|
||
return "KAZE";
|
||
case kFeatureOrbOctree:
|
||
return "ORB-OCTREE";
|
||
case kFeatureSuperPointTorch:
|
||
return "SUPERPOINT";
|
||
case kFeatureSurfFreak:
|
||
return "SURF+Freak";
|
||
case kFeatureGfttDaisy:
|
||
return "GFTT+Daisy";
|
||
case kFeatureSurfDaisy:
|
||
return "SURF+Daisy";
|
||
case kFeaturePyDetector:
|
||
return "PyDetector";
|
||
case kFeatureSuperPointRpautrat:
|
||
return "SUPERPOINT-RPAUTRAT";
|
||
default:
|
||
return "Unknown";
|
||
}
|
||
}
|
||
|
||
/** @brief Creates a detector from **Kp/DetectorStrategy** in @p parameters. Caller owns the pointer. */
|
||
static Feature2D * create(const ParametersMap & parameters = ParametersMap());
|
||
/** @brief Creates a detector of the given @p type. Caller owns the pointer. */
|
||
static Feature2D * create(Feature2D::Type type, const ParametersMap & parameters = ParametersMap());
|
||
|
||
/** @brief Returns true if @p type is available (RTAB-Map is built with it). */
|
||
static bool isAvailable(Feature2D::Type type);
|
||
|
||
/** @brief Keeps keypoints whose depth at (u,v) is in (@p minDepth, @p maxDepth). */
|
||
static void filterKeypointsByDepth(
|
||
std::vector<cv::KeyPoint> & keypoints,
|
||
const cv::Mat & depth,
|
||
float minDepth,
|
||
float maxDepth);
|
||
static void filterKeypointsByDepth(
|
||
std::vector<cv::KeyPoint> & keypoints,
|
||
cv::Mat & descriptors,
|
||
const cv::Mat & depth,
|
||
float minDepth,
|
||
float maxDepth);
|
||
static void filterKeypointsByDepth(
|
||
std::vector<cv::KeyPoint> & keypoints,
|
||
cv::Mat & descriptors,
|
||
std::vector<cv::Point3f> & keypoints3D,
|
||
float minDepth,
|
||
float maxDepth);
|
||
|
||
/** @brief Keeps keypoints with stereo disparity ≥ @p minDisparity. */
|
||
static void filterKeypointsByDisparity(
|
||
std::vector<cv::KeyPoint> & keypoints,
|
||
const cv::Mat & disparity,
|
||
float minDisparity);
|
||
static void filterKeypointsByDisparity(
|
||
std::vector<cv::KeyPoint> & keypoints,
|
||
cv::Mat & descriptors,
|
||
const cv::Mat & disparity,
|
||
float minDisparity);
|
||
|
||
/** @brief Reduces keypoint count (by response or SSC spatial distribution). */
|
||
static void limitKeypoints(std::vector<cv::KeyPoint> & keypoints, int maxKeypoints, const cv::Size & imageSize = cv::Size(), bool ssc = false);
|
||
static void limitKeypoints(std::vector<cv::KeyPoint> & keypoints, cv::Mat & descriptors, int maxKeypoints, const cv::Size & imageSize = cv::Size(), bool ssc = false);
|
||
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);
|
||
static void limitKeypoints(const std::vector<cv::KeyPoint> & keypoints, std::vector<bool> & inliers, int maxKeypoints, const cv::Size & imageSize = cv::Size(), bool ssc = false);
|
||
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);
|
||
|
||
/** @brief ROI from **Kp/RoiRatios** string (`"left top right bottom"` fractions). */
|
||
static cv::Rect computeRoi(const cv::Mat & image, const std::string & roiRatios);
|
||
static cv::Rect computeRoi(const cv::Mat & image, const std::vector<float> & roiRatios);
|
||
|
||
int getMaxFeatures() const {return maxFeatures_;}
|
||
bool getSSC() const {return SSC_;}
|
||
float getMinDepth() const {return _minDepth;}
|
||
float getMaxDepth() const {return _maxDepth;}
|
||
int getGridRows() const {return gridRows_;}
|
||
int getGridCols() const {return gridCols_;}
|
||
|
||
public:
|
||
virtual ~Feature2D();
|
||
|
||
/** @brief Detects keypoints in a grayscale @p image (CV_8UC1); optional depth or 8U mask. */
|
||
std::vector<cv::KeyPoint> generateKeypoints(
|
||
const cv::Mat & image,
|
||
const cv::Mat & mask = cv::Mat());
|
||
/** @brief Computes descriptors for @p keypoints (may shrink the list in some detectors). */
|
||
cv::Mat generateDescriptors(
|
||
const cv::Mat & image,
|
||
std::vector<cv::KeyPoint> & keypoints) const;
|
||
/** @brief Back-projects keypoints to 3D using depth or stereo in @p data. */
|
||
std::vector<cv::Point3f> generateKeypoints3D(
|
||
const SensorData & data,
|
||
const std::vector<cv::KeyPoint> & keypoints) const;
|
||
|
||
virtual void parseParameters(const ParametersMap & parameters);
|
||
virtual const ParametersMap & getParameters() const {return parameters_;}
|
||
virtual Feature2D::Type getType() const = 0;
|
||
|
||
/** @brief Returns true when a GPU/CUDA code path **could** be used by
|
||
* this detector on this host: i.e. the build was compiled with the
|
||
* matching GPU support AND a CUDA-capable device is detected at
|
||
* runtime. This is a capability probe -- it does NOT reflect whether
|
||
* the current instance is actually configured to run on GPU (that
|
||
* depends on per-detector parameters like SURF/GpuVersion). Defaults
|
||
* to false; subclasses with a GPU backend override it. */
|
||
virtual bool isGpuAvailable() const {return false;}
|
||
|
||
protected:
|
||
Feature2D(const ParametersMap & parameters = ParametersMap());
|
||
|
||
private:
|
||
virtual std::vector<cv::KeyPoint> generateKeypointsImpl(const cv::Mat & image, const cv::Rect & roi, const cv::Mat & mask = cv::Mat()) = 0;
|
||
virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const = 0;
|
||
|
||
private:
|
||
ParametersMap parameters_;
|
||
int maxFeatures_;
|
||
bool SSC_;
|
||
float _maxDepth; // 0=inf
|
||
float _minDepth;
|
||
std::vector<float> _roiRatios; // size 4
|
||
int _subPixWinSize;
|
||
int _subPixIterations;
|
||
double _subPixEps;
|
||
int gridRows_;
|
||
int gridCols_;
|
||
// Stereo stuff
|
||
Stereo * _stereo;
|
||
};
|
||
|
||
/** @brief SURF detector and descriptor (non-free / xfeatures2d depending on OpenCV build). */
|
||
class RTABMAP_CORE_EXPORT SURF : public Feature2D
|
||
{
|
||
public:
|
||
SURF(const ParametersMap & parameters = ParametersMap());
|
||
virtual ~SURF();
|
||
|
||
virtual void parseParameters(const ParametersMap & parameters) override;
|
||
virtual Feature2D::Type getType() const override {return kFeatureSurf;}
|
||
virtual bool isGpuAvailable() const override;
|
||
|
||
private:
|
||
virtual std::vector<cv::KeyPoint> generateKeypointsImpl(const cv::Mat & image, const cv::Rect & roi, const cv::Mat & mask = cv::Mat()) override;
|
||
virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
|
||
|
||
private:
|
||
double hessianThreshold_;
|
||
int nOctaves_;
|
||
int nOctaveLayers_;
|
||
bool extended_;
|
||
bool upright_;
|
||
float gpuKeypointsRatio_;
|
||
bool gpuVersion_;
|
||
|
||
cv::Ptr<CV_SURF> _surf;
|
||
cv::Ptr<CV_SURF_GPU> _gpuSurf;
|
||
};
|
||
|
||
/** @brief SIFT detector and descriptor (optional GPU / CudaSift). */
|
||
class RTABMAP_CORE_EXPORT SIFT : public Feature2D
|
||
{
|
||
public:
|
||
SIFT(const ParametersMap & parameters = ParametersMap());
|
||
virtual ~SIFT();
|
||
|
||
virtual void parseParameters(const ParametersMap & parameters) override;
|
||
virtual Feature2D::Type getType() const override {return kFeatureSift;}
|
||
virtual bool isGpuAvailable() const override;
|
||
|
||
private:
|
||
virtual std::vector<cv::KeyPoint> generateKeypointsImpl(const cv::Mat & image, const cv::Rect & roi, const cv::Mat & mask = cv::Mat()) override;
|
||
virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
|
||
|
||
private:
|
||
int nOctaveLayers_;
|
||
double contrastThreshold_;
|
||
double edgeThreshold_;
|
||
double sigma_;
|
||
bool preciseUpscale_;
|
||
bool rootSIFT_;
|
||
bool gpu_;
|
||
float gaussianThreshold_;
|
||
float maxGaussianThreshold_;
|
||
bool upscale_;
|
||
|
||
cv::Ptr<CV_SIFT> sift_;
|
||
SiftData * cudaSiftData_;
|
||
float * cudaSiftMemory_;
|
||
cv::Size cudaSiftMemorySize_;
|
||
cv::Mat cudaSiftDescriptors_;
|
||
bool cudaSiftUpscaling_;
|
||
};
|
||
|
||
/** @brief ORB detector and descriptor (optional GPU). */
|
||
class RTABMAP_CORE_EXPORT ORB : public Feature2D
|
||
{
|
||
public:
|
||
ORB(const ParametersMap & parameters = ParametersMap());
|
||
virtual ~ORB();
|
||
|
||
virtual void parseParameters(const ParametersMap & parameters) override;
|
||
virtual Feature2D::Type getType() const override {return kFeatureOrb;}
|
||
virtual bool isGpuAvailable() const override;
|
||
|
||
private:
|
||
virtual std::vector<cv::KeyPoint> generateKeypointsImpl(const cv::Mat & image, const cv::Rect & roi, const cv::Mat & mask = cv::Mat()) override;
|
||
virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
|
||
|
||
private:
|
||
float scaleFactor_;
|
||
int nLevels_;
|
||
int edgeThreshold_;
|
||
int firstLevel_;
|
||
int WTA_K_;
|
||
int scoreType_;
|
||
int patchSize_;
|
||
bool gpu_;
|
||
|
||
int fastThreshold_;
|
||
bool nonmaxSuppresion_;
|
||
|
||
cv::Ptr<CV_ORB> _orb;
|
||
cv::Ptr<CV_ORB_GPU> _gpuOrb;
|
||
};
|
||
|
||
/** @brief FAST corner detector only (no descriptor). */
|
||
class RTABMAP_CORE_EXPORT FAST : public Feature2D
|
||
{
|
||
public:
|
||
FAST(const ParametersMap & parameters = ParametersMap());
|
||
virtual ~FAST();
|
||
|
||
virtual void parseParameters(const ParametersMap & parameters) override;
|
||
virtual Feature2D::Type getType() const override {return kFeatureUndef;}
|
||
virtual bool isGpuAvailable() const override;
|
||
|
||
private:
|
||
virtual std::vector<cv::KeyPoint> generateKeypointsImpl(const cv::Mat & image, const cv::Rect & roi, const cv::Mat & mask = cv::Mat()) override;
|
||
virtual cv::Mat generateDescriptorsImpl(const cv::Mat &, std::vector<cv::KeyPoint> &) const override {return cv::Mat();}
|
||
|
||
private:
|
||
int threshold_;
|
||
bool nonmaxSuppression_;
|
||
bool gpu_;
|
||
double gpuKeypointsRatio_;
|
||
int minThreshold_;
|
||
int maxThreshold_;
|
||
int gridRows_;
|
||
int gridCols_;
|
||
int fastCV_;
|
||
|
||
bool fastCVinit_;
|
||
int fastCVMaxFeatures_;
|
||
int fastCVLastImageHeight_;
|
||
uint32_t* fastCVCorners_= NULL;
|
||
uint32_t* fastCVCornerScores_ = NULL;
|
||
void* fastCVTempBuf_ = NULL;
|
||
|
||
cv::Ptr<cv::FeatureDetector> _fast;
|
||
cv::Ptr<CV_FAST_GPU> _gpuFast;
|
||
};
|
||
|
||
/** @brief FAST corners + BRIEF descriptors. */
|
||
class RTABMAP_CORE_EXPORT FAST_BRIEF : public FAST
|
||
{
|
||
public:
|
||
FAST_BRIEF(const ParametersMap & parameters = ParametersMap());
|
||
virtual ~FAST_BRIEF();
|
||
|
||
virtual void parseParameters(const ParametersMap & parameters) override;
|
||
virtual Feature2D::Type getType() const override {return kFeatureFastBrief;}
|
||
|
||
private:
|
||
virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
|
||
|
||
private:
|
||
int bytes_;
|
||
|
||
cv::Ptr<CV_BRIEF> _brief;
|
||
};
|
||
|
||
/** @brief FAST corners + FREAK descriptors. */
|
||
class RTABMAP_CORE_EXPORT FAST_FREAK : public FAST
|
||
{
|
||
public:
|
||
FAST_FREAK(const ParametersMap & parameters = ParametersMap());
|
||
virtual ~FAST_FREAK();
|
||
|
||
virtual void parseParameters(const ParametersMap & parameters) override;
|
||
virtual Feature2D::Type getType() const override {return kFeatureFastFreak;}
|
||
|
||
private:
|
||
virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
|
||
|
||
private:
|
||
bool orientationNormalized_;
|
||
bool scaleNormalized_;
|
||
float patternScale_;
|
||
int nOctaves_;
|
||
|
||
cv::Ptr<CV_FREAK> _freak;
|
||
};
|
||
|
||
/** @brief Good-features-to-track detector (Shi–Tomasi / Harris). */
|
||
class RTABMAP_CORE_EXPORT GFTT : public Feature2D
|
||
{
|
||
public:
|
||
GFTT(const ParametersMap & parameters = ParametersMap());
|
||
virtual ~GFTT();
|
||
|
||
virtual void parseParameters(const ParametersMap & parameters) override;
|
||
virtual bool isGpuAvailable() const override;
|
||
|
||
private:
|
||
virtual std::vector<cv::KeyPoint> generateKeypointsImpl(const cv::Mat & image, const cv::Rect & roi, const cv::Mat & mask = cv::Mat()) override;
|
||
|
||
private:
|
||
double _qualityLevel;
|
||
double _minDistance;
|
||
int _blockSize;
|
||
bool _useHarrisDetector;
|
||
double _k;
|
||
bool _gpu;
|
||
|
||
cv::Ptr<CV_GFTT> _gftt;
|
||
cv::Ptr<CV_GFTT_GPU> _gpuGftt;
|
||
};
|
||
|
||
/** @brief GFTT corners + BRIEF descriptors. */
|
||
class RTABMAP_CORE_EXPORT GFTT_BRIEF : public GFTT
|
||
{
|
||
public:
|
||
GFTT_BRIEF(const ParametersMap & parameters = ParametersMap());
|
||
virtual ~GFTT_BRIEF();
|
||
|
||
virtual void parseParameters(const ParametersMap & parameters) override;
|
||
virtual Feature2D::Type getType() const override {return kFeatureGfttBrief;}
|
||
|
||
private:
|
||
virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
|
||
|
||
private:
|
||
int bytes_;
|
||
|
||
cv::Ptr<CV_BRIEF> _brief;
|
||
};
|
||
|
||
/** @brief GFTT corners + FREAK descriptors. */
|
||
class RTABMAP_CORE_EXPORT GFTT_FREAK : public GFTT
|
||
{
|
||
public:
|
||
GFTT_FREAK(const ParametersMap & parameters = ParametersMap());
|
||
virtual ~GFTT_FREAK();
|
||
|
||
virtual void parseParameters(const ParametersMap & parameters) override;
|
||
virtual Feature2D::Type getType() const override {return kFeatureGfttFreak;}
|
||
|
||
private:
|
||
virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
|
||
|
||
private:
|
||
bool orientationNormalized_;
|
||
bool scaleNormalized_;
|
||
float patternScale_;
|
||
int nOctaves_;
|
||
|
||
cv::Ptr<CV_FREAK> _freak;
|
||
};
|
||
|
||
/** @brief SURF detector + FREAK descriptors. */
|
||
class RTABMAP_CORE_EXPORT SURF_FREAK : public SURF
|
||
{
|
||
public:
|
||
SURF_FREAK(const ParametersMap & parameters = ParametersMap());
|
||
virtual ~SURF_FREAK();
|
||
|
||
virtual void parseParameters(const ParametersMap & parameters) override;
|
||
virtual Feature2D::Type getType() const override {return kFeatureSurfFreak;}
|
||
|
||
private:
|
||
virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
|
||
|
||
private:
|
||
bool orientationNormalized_;
|
||
bool scaleNormalized_;
|
||
float patternScale_;
|
||
int nOctaves_;
|
||
|
||
cv::Ptr<CV_FREAK> _freak;
|
||
};
|
||
|
||
/** @brief GFTT corners + ORB descriptors (common default when SURF is unavailable). */
|
||
class RTABMAP_CORE_EXPORT GFTT_ORB : public GFTT
|
||
{
|
||
public:
|
||
GFTT_ORB(const ParametersMap & parameters = ParametersMap());
|
||
virtual ~GFTT_ORB();
|
||
|
||
virtual void parseParameters(const ParametersMap & parameters) override;
|
||
virtual Feature2D::Type getType() const override {return kFeatureGfttOrb;}
|
||
|
||
private:
|
||
virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
|
||
|
||
private:
|
||
ORB _orb;
|
||
};
|
||
|
||
/** @brief BRISK detector and descriptor. */
|
||
class RTABMAP_CORE_EXPORT BRISK : public Feature2D
|
||
{
|
||
public:
|
||
BRISK(const ParametersMap & parameters = ParametersMap());
|
||
virtual ~BRISK();
|
||
|
||
virtual void parseParameters(const ParametersMap & parameters) override;
|
||
virtual Feature2D::Type getType() const override {return kFeatureBrisk;}
|
||
|
||
private:
|
||
virtual std::vector<cv::KeyPoint> generateKeypointsImpl(const cv::Mat & image, const cv::Rect & roi, const cv::Mat & mask = cv::Mat()) override;
|
||
virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
|
||
|
||
private:
|
||
int thresh_;
|
||
int octaves_;
|
||
float patternScale_;
|
||
|
||
cv::Ptr<CV_BRISK> brisk_;
|
||
};
|
||
|
||
/** @brief KAZE detector and descriptor (OpenCV 3+). */
|
||
class RTABMAP_CORE_EXPORT KAZE : public Feature2D
|
||
{
|
||
public:
|
||
KAZE(const ParametersMap & parameters = ParametersMap());
|
||
virtual ~KAZE();
|
||
|
||
virtual void parseParameters(const ParametersMap & parameters) override;
|
||
virtual Feature2D::Type getType() const override { return kFeatureKaze; }
|
||
|
||
private:
|
||
virtual std::vector<cv::KeyPoint> generateKeypointsImpl(const cv::Mat & image, const cv::Rect & roi, const cv::Mat & mask = cv::Mat()) override;
|
||
virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
|
||
|
||
private:
|
||
bool extended_;
|
||
bool upright_;
|
||
float threshold_;
|
||
int nOctaves_;
|
||
int nOctaveLayers_;
|
||
int diffusivity_;
|
||
|
||
#if CV_MAJOR_VERSION > 2
|
||
cv::Ptr<CV_KAZE> kaze_;
|
||
#endif
|
||
};
|
||
|
||
/** @brief ORB with octree spatial distribution (RTAB-Map must be built with OCTREE enabled). */
|
||
class RTABMAP_CORE_EXPORT ORBOctree : public Feature2D
|
||
{
|
||
public:
|
||
ORBOctree(const ParametersMap & parameters = ParametersMap());
|
||
virtual ~ORBOctree();
|
||
|
||
virtual void parseParameters(const ParametersMap & parameters) override;
|
||
virtual Feature2D::Type getType() const override {return kFeatureOrbOctree;}
|
||
|
||
private:
|
||
virtual std::vector<cv::KeyPoint> generateKeypointsImpl(const cv::Mat & image, const cv::Rect & roi, const cv::Mat & mask = cv::Mat()) override;
|
||
virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
|
||
|
||
private:
|
||
float scaleFactor_;
|
||
int nLevels_;
|
||
int patchSize_;
|
||
int edgeThreshold_;
|
||
int fastThreshold_;
|
||
int fastMinThreshold_;
|
||
|
||
cv::Ptr<ORBextractor> _orb;
|
||
cv::Mat descriptors_;
|
||
};
|
||
|
||
/** @brief SuperPoint via LibTorch (RTAB-Map must be built with libtorch support). */
|
||
class RTABMAP_CORE_EXPORT SuperPointTorch : public Feature2D
|
||
{
|
||
public:
|
||
SuperPointTorch(const ParametersMap & parameters = ParametersMap());
|
||
virtual ~SuperPointTorch();
|
||
|
||
virtual void parseParameters(const ParametersMap & parameters) override;
|
||
virtual Feature2D::Type getType() const override { return kFeatureSuperPointTorch; }
|
||
virtual bool isGpuAvailable() const override;
|
||
|
||
private:
|
||
virtual std::vector<cv::KeyPoint> generateKeypointsImpl(const cv::Mat & image, const cv::Rect & roi, const cv::Mat & mask = cv::Mat()) override;
|
||
virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
|
||
|
||
cv::Ptr<SPDetector> superPoint_;
|
||
|
||
std::string path_;
|
||
float threshold_;
|
||
bool nms_;
|
||
int minDistance_;
|
||
bool cuda_;
|
||
};
|
||
|
||
/** @brief SuperPoint (rpautrat) via Torch + Python (RTAB-Map must be built with libtorch and Python support). */
|
||
class RTABMAP_CORE_EXPORT SuperPointRpautrat : public Feature2D
|
||
{
|
||
public:
|
||
SuperPointRpautrat(const ParametersMap & parameters = ParametersMap());
|
||
virtual ~SuperPointRpautrat();
|
||
|
||
virtual void parseParameters(const ParametersMap & parameters) override;
|
||
virtual Feature2D::Type getType() const override { return kFeatureSuperPointRpautrat; }
|
||
virtual bool isGpuAvailable() const override;
|
||
|
||
private:
|
||
virtual std::vector<cv::KeyPoint> generateKeypointsImpl(const cv::Mat & image, const cv::Rect & roi, const cv::Mat & mask = cv::Mat()) override;
|
||
virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
|
||
|
||
cv::Ptr<SPDetectorRpautrat> superPoint_;
|
||
|
||
std::string superpointWeightsPath_;
|
||
std::string superpointModelPath_;
|
||
std::string outputDir_;
|
||
float threshold_;
|
||
bool nms_;
|
||
int minDistance_;
|
||
bool cuda_;
|
||
};
|
||
|
||
/** @brief GFTT corners + DAISY descriptors (OpenCV 3+ xfeatures2d). */
|
||
class RTABMAP_CORE_EXPORT GFTT_DAISY : public GFTT
|
||
{
|
||
public:
|
||
GFTT_DAISY(const ParametersMap & parameters = ParametersMap());
|
||
virtual ~GFTT_DAISY();
|
||
|
||
virtual void parseParameters(const ParametersMap & parameters) override;
|
||
virtual Feature2D::Type getType() const override {return kFeatureGfttDaisy;}
|
||
|
||
private:
|
||
virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
|
||
|
||
private:
|
||
bool orientationNormalized_;
|
||
bool scaleNormalized_;
|
||
float patternScale_;
|
||
int nOctaves_;
|
||
|
||
#if CV_MAJOR_VERSION > 2
|
||
cv::Ptr<CV_DAISY> _daisy;
|
||
#endif
|
||
};
|
||
|
||
/** @brief SURF detector + DAISY descriptors (OpenCV 3+ xfeatures2d). */
|
||
class RTABMAP_CORE_EXPORT SURF_DAISY : public SURF
|
||
{
|
||
public:
|
||
SURF_DAISY(const ParametersMap & parameters = ParametersMap());
|
||
virtual ~SURF_DAISY();
|
||
|
||
virtual void parseParameters(const ParametersMap & parameters) override;
|
||
virtual Feature2D::Type getType() const override {return kFeatureSurfDaisy;}
|
||
|
||
private:
|
||
virtual cv::Mat generateDescriptorsImpl(const cv::Mat & image, std::vector<cv::KeyPoint> & keypoints) const override;
|
||
|
||
private:
|
||
bool orientationNormalized_;
|
||
bool scaleNormalized_;
|
||
float patternScale_;
|
||
int nOctaves_;
|
||
|
||
#if CV_MAJOR_VERSION > 2
|
||
cv::Ptr<CV_DAISY> _daisy;
|
||
#endif
|
||
};
|
||
|
||
}
|
||
|
||
#endif /* FEATURES2D_H_ */
|