NDEVR
API Documentation
ORBmatcher.h
1
2#pragma once
3#include "Base/Headers/Buffer.hpp"
4#include "Base/Headers/Set.h"
5#include <opencv2/core/core.hpp>
6#include <opencv2/features2d/features2d.hpp>
7#include "OrbSLAM/Thirdparty/Sophus/sophus/sim3.hpp"
8#include "OrbSLAM/Headers/MapPointProjection.h"
9#include <utility>
10namespace cv
11{
12 class Mat;
13}
14
15namespace NDEVR
16{
17 class MapPoint;
18 class Frame;
19 class KeyFrame;
26 {
27 public:
28
33 ORBmatcher(float nnratio=0.6f, bool checkOri=true);
38 void setup(float mfNNratio = 0.6f, bool checkOri = true);
44 static uint01 DescriptorDistance(const cv::Mat &a, const cv::Mat &b);
45
46 // Search matches between Frame keypoints and projected MapPoints. Returns number of matches
47 // Used to track the local map (Tracking)
48 uint04 searchByProjection(Frame &F, const Buffer<MapPointProjection> &vpMapPoints, const fltp04 th=3.0f, const bool bFarPoints = false, const float thFarPoints = 50.0f);
49
50 // Project MapPoints tracked in last frame into the current frame and search matches.
51 // Used to track from previous frame (Tracking)
52 uint04 searchByProjection(Frame &CurrentFrame, const Frame &LastFrame, const fltp04 th, const bool bMono);
53
54 // Project MapPoints seen in KeyFrame into the Frame and search matches.
55 // Used in relocalisation (Tracking)
56 uint04 searchByProjection(Frame &frame, KeyFrame* pKF, const Set<MapPoint*> &sAlreadyFound, const float th, uint04 ORBdist);
57
58 // Project MapPoints using a Similarity Transformation and search matches.
59 // Used in loop detection (Loop Closing)
60 uint04 searchByProjection(KeyFrame* pKF, Sophus::Sim3<g_type>& Scw, const Buffer<MapPoint*> &vpPoints, Buffer<MapPoint*> &vpMatched, uint04 th, fltp04 ratioHamming=1.0f);
61
62 // Project MapPoints using a Similarity Transformation and search matches.
63 // Used in Place Recognition (Loop Closing and Merging)
64 uint04 searchByProjection(KeyFrame* pKF, Sophus::Sim3<g_type>& Scw, const Buffer<MapPoint*> &vpPoints, const Buffer<KeyFrame*> &vpPointsKFs, Buffer<MapPoint*> &vpMatched, Buffer<KeyFrame*> &vpMatchedKF, fltp04 th, fltp04 ratioHamming=1.0f);
65
66 // Search matches between MapPoints in a KeyFrame and ORB in a Frame.
67 // Brute force constrained to ORB that belong to the same vocabulary node (at a certain level)
68 // Used in Relocalisation and Loop Detection
69 uint04 searchByBoW(KeyFrame *pKF, const Frame &F, Buffer<MapPoint*>& vpMapPointMatches);
70 uint04 searchByBoW(KeyFrame *pKF1, KeyFrame* pKF2, Buffer<MapPoint*> &vpMatches12);
71
72 // Matching for the Map Initialization (only used in the monocular case)
73 uint04 searchForInitialization(Frame &F1, Frame &F2, Buffer<cv::Point2f> &vbPrevMatched, Buffer<uint04> &vnMatches12, int windowSize=10);
74
75 // Matching to triangulate new MapPoints. Check Epipolar Constraint.
76 uint04 searchForTriangulation(KeyFrame *pKF1, KeyFrame* pKF2, Buffer<Vector<2, uint04>>& vMatchedPairs, const bool bOnlyStereo, const bool bCoarse = false);
77
78 // Search matches between MapPoints seen in KF1 and KF2 transforming by a Sim3 [s12*R12|t12]
79 // In the stereo and RGB-t_dim case, s12=1
80 // int SearchBySim3(KeyFrame* pKF1, KeyFrame* pKF2, Buffer<MapPoint *> &vpMatches12, const float &s12, const cv::Mat &R12, const cv::Mat &t12, const float th);
81 int SearchBySim3(KeyFrame* pKF1, KeyFrame* pKF2, Buffer<MapPoint *> &vpMatches12, const Sophus::Sim3<g_type>& S12, const float th);
82
83 // Project MapPoints into KeyFrame and search for duplicated MapPoints.
84 int Fuse(KeyFrame* pKF, const Buffer<MapPoint *> &vpMapPoints, const float th=3.0, const bool bRight = false);
85
86 // Project MapPoints into KeyFrame using a given Sim3 and search for duplicated MapPoints.
87 int Fuse(KeyFrame* pKF, Sophus::Sim3<g_type>& Scw, const Buffer<MapPoint*> &vpPoints, float th, Buffer<MapPoint *> &vpReplacePoint);
88 public:
89
90 static constexpr uint04 TH_LOW = 50U;
91 static constexpr uint04 TH_HIGH = 100U;
92 static constexpr uint04 HISTO_LENGTH = 30U;
93 EIGEN_MAKE_ALIGNED_OPERATOR_NEW
94
95 protected:
96
97 static float RadiusByViewingCos(fltp04 viewCos);
98 //checks orientation and returns removed amount
99 void computeOrientationIdx(const cv::KeyPoint& k0, const cv::KeyPoint& k1, uint04 idx);
100 uint04 checkOrientation(Frame& frame);
101 uint04 checkOrientation(Buffer<MapPoint*>& vpMatches12);
102 uint04 checkOrientation(Buffer<uint04>& vpMatches12);
103 void computeMaxima(uint04& ind1, uint04& ind2, uint04& ind3) const;
104 void resetRotationHistory();
105 Buffer<uint04> m_rotational_history[HISTO_LENGTH];
106 Buffer<uint04> m_indices;
107 Buffer<uint04> m_v_indices;
108 float mfNNratio = 0.0f;
109 bool m_check_orientation = false;
110 };
111
112}
The equivelent of std::vector but with a bit more control.
Definition Buffer.hpp:58
Represents a single image frame with extracted features and pose information.
Definition Frame.h:111
A keyframe in the SLAM map, derived from Frame.
Definition KeyFrame.h:31
A 3D point in the SLAM map observed by multiple keyframes.
Definition MapPoint.h:24
ORBmatcher(float nnratio=0.6f, bool checkOri=true)
Constructs an ORB matcher.
static uint01 DescriptorDistance(const cv::Mat &a, const cv::Mat &b)
Computes the Hamming distance between two ORB descriptors.
void setup(float mfNNratio=0.6f, bool checkOri=true)
Reconfigures the matcher parameters.
Container that stores unique elements in no particular order, and which allow for fast retrieval or i...
Definition Set.h:59
A fixed-size array with N dimensions used as the basis for geometric and mathematical types.
Definition Vector.hpp:62
The primary namespace for the NDEVR SDK.
float fltp04
Defines an alias representing a 4 byte floating-point number Bit layout is as follows: -Sign: 1 bit a...
uint32_t uint04
-Defines an alias representing a 4 byte, unsigned integer -Can represent exact integer values 0 throu...
uint8_t uint01
-Defines an alias representing a 1 byte, unsigned integer -Can represent exact integer values 0 throu...