SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
FeatureExtractorFactory.cpp
Go to the documentation of this file.
2 #include <ORBextractor.h>
3 #include <BRIEFextractor.h>
4 #include <GLSLextractor.h>
5 
6 using namespace ORB_SLAM2;
7 
8 //-----------------------------------------------------------------------------
10 {
11  _extractorIdToNames.resize(ExtractorType_Last);
12  _extractorIdToNames[ExtractorType_FAST_ORBS_1000] = "FAST-ORBS-1000";
13  _extractorIdToNames[ExtractorType_FAST_ORBS_2000] = "FAST-ORBS-2000";
14  _extractorIdToNames[ExtractorType_FAST_ORBS_3000] = "FAST-ORBS-3000";
15  _extractorIdToNames[ExtractorType_FAST_ORBS_4000] = "FAST-ORBS-4000";
16  _extractorIdToNames[ExtractorType_FAST_BRIEF_1000] = "FAST-BRIEF-1000";
17  _extractorIdToNames[ExtractorType_FAST_BRIEF_2000] = "FAST-BRIEF-2000";
18  _extractorIdToNames[ExtractorType_FAST_BRIEF_3000] = "FAST-BRIEF-3000";
19  _extractorIdToNames[ExtractorType_FAST_BRIEF_4000] = "FAST-BRIEF-4000";
20 }
21 //-----------------------------------------------------------------------------
22 std::unique_ptr<KPextractor> FeatureExtractorFactory::make(ExtractorType id,
23  const cv::Size& videoFrameSize,
24  int nLevels)
25 {
26  switch (id)
27  {
29  return orbExtractor(1000, nLevels);
31  return orbExtractor(2000, nLevels);
33  return orbExtractor(3000, nLevels);
35  return orbExtractor(4000, nLevels);
37  return briefExtractor(1000, nLevels);
39  return briefExtractor(2000, nLevels);
41  return briefExtractor(3000, nLevels);
43  return briefExtractor(4000, nLevels);
44  /*
45  #ifndef TARGET_OS_IOS
46  case ExtractorType_GLSL_1:
47  return glslExtractor(videoFrameSize, 16, 16, 0.5f, 0.10f, 1.9f, 1.3f);
48  case ExtractorType_GLSL:
49  return glslExtractor(videoFrameSize, 16, 16, 0.5f, 0.10f, 1.9f, 1.4f);
50  #endif
51  */
52  default:
53  return orbExtractor(1000, nLevels);
54  }
55 }
56 //-----------------------------------------------------------------------------
57 std::unique_ptr<KPextractor> FeatureExtractorFactory::make(std::string extractorType,
58  const cv::Size& videoFrameSize,
59  int nLevels)
60 {
61  std::unique_ptr<KPextractor> result = nullptr;
62 
63  for (int i = 0; i < _extractorIdToNames.size(); i++)
64  {
65  if (_extractorIdToNames[i] == extractorType)
66  {
67  result = make((ExtractorType)i, videoFrameSize, nLevels);
68  break;
69  }
70  }
71 
72  return result;
73 }
74 //-----------------------------------------------------------------------------
75 std::unique_ptr<KPextractor> FeatureExtractorFactory::orbExtractor(int nf, int nLevels)
76 {
77  float fScaleFactor = 1.2f;
78  int fIniThFAST = 20;
79  int fMinThFAST = 7;
80  return std::make_unique<ORB_SLAM2::ORBextractor>(nf,
81  fScaleFactor,
82  nLevels,
83  fIniThFAST,
84  fMinThFAST);
85 }
86 //-----------------------------------------------------------------------------
87 std::unique_ptr<KPextractor> FeatureExtractorFactory::briefExtractor(int nf,
88  int nLevels)
89 {
90  float fScaleFactor = 1.2f;
91  int fIniThFAST = 20;
92  int fMinThFAST = 7;
93  return std::make_unique<ORB_SLAM2::BRIEFextractor>(nf,
94  fScaleFactor,
95  nLevels,
96  fIniThFAST,
97  fMinThFAST);
98 }
99 //-----------------------------------------------------------------------------
100 #ifndef TARGET_OS_IOS
101 std::unique_ptr<KPextractor> FeatureExtractorFactory::glslExtractor(const cv::Size&
102  videoFrameSize,
103  int nbKeypointsBigSigma,
104  int nbKeypointsSmallSigma,
105  float highThrs,
106  float lowThrs,
107  float bigSigma,
108  float smallSigma)
109 {
110  // int nbKeypointsBigSigma, int nbKeypointsSmallSigma, float highThrs, float lowThrs, float bigSigma, float smallSigma
111  return std::make_unique<GLSLextractor>(videoFrameSize.width,
112  videoFrameSize.height,
113  nbKeypointsBigSigma,
114  nbKeypointsSmallSigma,
115  highThrs,
116  lowThrs,
117  bigSigma,
118  smallSigma);
119 }
120 //-----------------------------------------------------------------------------
121 #endif
@ ExtractorType_FAST_ORBS_2000
@ ExtractorType_FAST_ORBS_3000
@ ExtractorType_FAST_BRIEF_4000
@ ExtractorType_FAST_ORBS_1000
@ ExtractorType_FAST_ORBS_4000
@ ExtractorType_FAST_BRIEF_1000
@ ExtractorType_FAST_BRIEF_2000
@ ExtractorType_FAST_BRIEF_3000
@ ExtractorType_Last
std::unique_ptr< ORB_SLAM2::KPextractor > glslExtractor(const cv::Size &videoFrameSize, int nbKeypointsBigSigma, int nbKeypointsSmallSigma, float highThrs, float lowThrs, float bigSigma, float smallSigma)
std::unique_ptr< ORB_SLAM2::KPextractor > orbExtractor(int nf, int nLevels)
std::unique_ptr< ORB_SLAM2::KPextractor > briefExtractor(int nf, int nLevels)
std::unique_ptr< ORB_SLAM2::KPextractor > make(ExtractorType id, const cv::Size &videoFrameSize, int nLevels)