ORB SLA2
MapPoint.h
1 
21 #ifndef MAPPOINT_H
22 #define MAPPOINT_H
23 
24 #include"KeyFrame.h"
25 #include"Frame.h"
26 #include"Map.h"
27 
28 #include<opencv2/core/core.hpp>
29 #include<mutex>
30 
31 namespace ORB_SLAM2
32 {
33 
34 class KeyFrame;
35 class Map;
36 class Frame;
37 
38 
39 class MapPoint
40 {
41 public:
42  MapPoint(const cv::Mat &Pos, KeyFrame* pRefKF, Map* pMap);
43  MapPoint(const cv::Mat &Pos, Map* pMap, Frame* pFrame, const int &idxF);
44 
45  void SetWorldPos(const cv::Mat &Pos);
46  cv::Mat GetWorldPos();
47 
48  cv::Mat GetNormal();
49  KeyFrame* GetReferenceKeyFrame();
50 
51  std::map<KeyFrame*,size_t> GetObservations();
52  int Observations();
53 
54  void AddObservation(KeyFrame* pKF,size_t idx);
55  void EraseObservation(KeyFrame* pKF);
56 
57  int GetIndexInKeyFrame(KeyFrame* pKF);
58  bool IsInKeyFrame(KeyFrame* pKF);
59 
60  void SetBadFlag();
61  bool isBad();
62 
63  void Replace(MapPoint* pMP);
64  MapPoint* GetReplaced();
65 
66  void IncreaseVisible(int n=1);
67  void IncreaseFound(int n=1);
68  float GetFoundRatio();
69  inline int GetFound(){
70  return mnFound;
71  }
72 
73  void ComputeDistinctiveDescriptors();
74 
75  cv::Mat GetDescriptor();
76 
77  void UpdateNormalAndDepth();
78 
79  float GetMinDistanceInvariance();
80  float GetMaxDistanceInvariance();
81  int PredictScale(const float &currentDist, KeyFrame*pKF);
82  int PredictScale(const float &currentDist, Frame* pF);
83 
84 public:
85  long unsigned int mnId;
86  static long unsigned int nNextId;
87  long int mnFirstKFid;
88  long int mnFirstFrame;
89  int nObs;
90 
91  // Variables used by the tracking
92  float mTrackProjX;
93  float mTrackProjY;
94  float mTrackProjXR;
95  bool mbTrackInView;
96  int mnTrackScaleLevel;
97  float mTrackViewCos;
98  long unsigned int mnTrackReferenceForFrame;
99  long unsigned int mnLastFrameSeen;
100 
101  // Variables used by local mapping
102  long unsigned int mnBALocalForKF;
103  long unsigned int mnFuseCandidateForKF;
104 
105  // Variables used by loop closing
106  long unsigned int mnLoopPointForKF;
107  long unsigned int mnCorrectedByKF;
108  long unsigned int mnCorrectedReference;
109  cv::Mat mPosGBA;
110  long unsigned int mnBAGlobalForKF;
111 
112 
113  static std::mutex mGlobalMutex;
114 
115 protected:
116 
117  // Position in absolute coordinates
118  cv::Mat mWorldPos;
119 
120  // Keyframes observing the point and associated index in keyframe
121  std::map<KeyFrame*,size_t> mObservations;
122 
123  // Mean viewing direction
124  cv::Mat mNormalVector;
125 
126  // Best descriptor to fast matching
127  cv::Mat mDescriptor;
128 
129  // Reference KeyFrame
130  KeyFrame* mpRefKF;
131 
132  // Tracking counters
133  int mnVisible;
134  int mnFound;
135 
136  // Bad flag (we do not currently erase MapPoint from memory)
137  bool mbBad;
138  MapPoint* mpReplaced;
139 
140  // Scale invariance distances
141  float mfMinDistance;
142  float mfMaxDistance;
143 
144  Map* mpMap;
145 
146  std::mutex mMutexPos;
147  std::mutex mMutexFeatures;
148 };
149 
150 } //namespace ORB_SLAM
151 
152 #endif // MAPPOINT_H
Definition: KeyFrame.h:43
Definition: Frame.h:43
Definition: Converter.cpp:24
Definition: MapPoint.h:39
Definition: Map.h:38