Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #ifndef __MAPMAKER_H
00015 #define __MAPMAKER_H
00016 #include <cvd/image.h>
00017 #include <cvd/byte.h>
00018 #include <cvd/thread.h>
00019
00020 #include "Map.h"
00021 #include "KeyFrame.h"
00022 #include "ATANCamera.h"
00023 #include <queue>
00024
00025
00026
00027
00028
00029 struct MapMakerData
00030 {
00031 std::set<KeyFrame*> sMeasurementKFs;
00032 std::set<KeyFrame*> sNeverRetryKFs;
00033 inline int GoodMeasCount()
00034 { return sMeasurementKFs.size(); }
00035 };
00036
00037
00038 class MapMaker : protected CVD::Thread
00039 {
00040 public:
00041 MapMaker(Map &m, const ATANCamera &cam);
00042 ~MapMaker();
00043
00044
00045 bool InitFromStereo(KeyFrame &kFirst, KeyFrame &kSecond,
00046 std::vector<std::pair<CVD::ImageRef, CVD::ImageRef> > &vMatches,
00047 SE3<> &se3CameraPos,
00048 SE3<> KFZeroDesiredCamFromWorld,
00049 SE3<> KFOneDesiredCamFromWorld);
00050
00051 bool InitFromStereo_OLD(KeyFrame &kFirst, KeyFrame &kSecond,
00052 std::vector<std::pair<CVD::ImageRef, CVD::ImageRef> > &vMatches,
00053 SE3<> &se3CameraPos);
00054
00055
00056 void AddKeyFrame(KeyFrame &k);
00057 void RequestReset();
00058 bool ResetDone();
00059 int QueueSize() { return mvpKeyFrameQueue.size() ;}
00060 bool NeedNewKeyFrame(KeyFrame &kCurrent);
00061 bool IsDistanceToNearestKeyFrameExcessive(KeyFrame &kCurrent);
00062
00063 double initialScaleFactor;
00064 double currentScaleFactor;
00065 double minKFWiggleDist;
00066 double minKFDist;
00067 double lastMetricDist;
00068 double lastWiggleDist;
00069
00070 protected:
00071
00072 Map &mMap;
00073 ATANCamera mCamera;
00074 virtual void run();
00075
00076
00077 SE3<> CalcPlaneAligner();
00078 void ApplyGlobalTransformationToMap(SE3<> se3NewFromOld);
00079 void ApplyGlobalScaleToMap(double dScale);
00080
00081
00082 void AddKeyFrameFromTopOfQueue();
00083 void ThinCandidates(KeyFrame &k, int nLevel);
00084 void AddSomeMapPoints(int nLevel);
00085 bool AddPointEpipolar(KeyFrame &kSrc, KeyFrame &kTarget, int nLevel, int nCandidate);
00086
00087 Vector<3> ReprojectPoint(SE3<> se3AfromB, const Vector<2> &v2A, const Vector<2> &v2B);
00088
00089
00090 void BundleAdjust(std::set<KeyFrame*>, std::set<KeyFrame*>, std::set<MapPoint*>, bool);
00091 void BundleAdjustAll();
00092 void BundleAdjustRecent();
00093
00094
00095 int ReFindInSingleKeyFrame(KeyFrame &k);
00096 void ReFindFromFailureQueue();
00097 void ReFindNewlyMade();
00098 void ReFindAll();
00099 bool ReFind_Common(KeyFrame &k, MapPoint &p);
00100 void SubPixelRefineMatches(KeyFrame &k, int nLevel);
00101
00102
00103 void Reset();
00104 void HandleBadPoints();
00105 double DistToNearestKeyFrame(KeyFrame &kCurrent);
00106 double KeyFrameLinearDist(KeyFrame &k1, KeyFrame &k2);
00107 KeyFrame* ClosestKeyFrame(KeyFrame &k);
00108 std::vector<KeyFrame*> NClosestKeyFrames(KeyFrame &k, unsigned int N);
00109 void RefreshSceneDepth(KeyFrame *pKF);
00110
00111
00112
00113 void GUICommandHandler(std::string sCommand, std::string sParams);
00114 static void GUICommandCallBack(void* ptr, std::string sCommand, std::string sParams);
00115 struct Command {std::string sCommand; std::string sParams; };
00116 std::vector<Command> mvQueuedCommands;
00117
00118
00119
00120 std::vector<KeyFrame*> mvpKeyFrameQueue;
00121 std::vector<std::pair<KeyFrame*, MapPoint*> > mvFailureQueue;
00122 std::queue<MapPoint*> mqNewQueue;
00123
00124 double mdWiggleScale;
00125
00126 GVars3::gvar3<double> mgvdWiggleScale;
00127 double mdWiggleScaleDepthNormalized;
00128
00129
00130 bool mbBundleConverged_Full;
00131 bool mbBundleConverged_Recent;
00132
00133
00134 bool mbResetRequested;
00135 bool mbResetDone;
00136 bool mbBundleAbortRequested;
00137 bool mbBundleRunning;
00138 bool mbBundleRunningIsRecent;
00139
00140
00141 };
00142
00143 #endif
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161