Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef __TRACKER_H
00022 #define __TRACKER_H
00023
00024 #include "MapMaker.h"
00025 #include "ATANCamera.h"
00026 #include "MiniPatch.h"
00027 #include "Relocaliser.h"
00028 #include "../Predictor.h"
00029
00030 #include <sstream>
00031 #include <vector>
00032 #include <list>
00033
00034
00035 class TrackerData;
00036 struct Trail
00037 {
00038 MiniPatch mPatch;
00039 CVD::ImageRef irCurrentPos;
00040 CVD::ImageRef irInitialPos;
00041 };
00042
00043 class Tracker
00044 {
00045 public:
00046 Tracker(CVD::ImageRef irVideoSize, const ATANCamera &c, Map &m, MapMaker &mm);
00047
00048
00049 void TrackFrame(CVD::Image<CVD::byte> &imFrame, bool bDraw);
00050 void TakeKF(bool force);
00051 void tryToRecover();
00052
00053 inline SE3<> GetCurrentPose() { return mse3CamFromWorld;}
00054
00055
00056 std::string GetMessageForUser();
00057
00058 inline void pressSpacebar() {mbUserPressedSpacebar = true;}
00059 inline void resetMap() {Reset();}
00060 int numPointsFound;
00061 int numPointsAttempted;
00062 enum {I_FIRST, I_SECOND, I_FAILED ,T_GOOD, T_DODGY, T_LOST, T_RECOVERED_GOOD, T_RECOVERED_DODGY, NOT_TRACKING, INITIALIZING, T_TOOK_KF} lastStepResult;
00063
00064
00065 double minKFTimeDist;
00066
00067
00068
00069
00070 inline void setPredictedCamFromW(SE3<>& camFromW) {predictedCFromW = camFromW;}
00071 inline void setLastFrameLost(bool lost, bool useGuessForRecovery = false) {lastFrameLost = lost; useGuess = useGuessForRecovery;};
00072
00073 protected:
00074 KeyFrame mCurrentKF;
00075
00076
00077 Map &mMap;
00078 MapMaker &mMapMaker;
00079 ATANCamera mCamera;
00080 Relocaliser mRelocaliser;
00081
00082 CVD::ImageRef mirSize;
00083
00084 void Reset();
00085 void RenderGrid();
00086
00087
00088 void TrackForInitialMap();
00089 enum {TRAIL_TRACKING_NOT_STARTED,
00090 TRAIL_TRACKING_STARTED,
00091 TRAIL_TRACKING_COMPLETE} mnInitialStage;
00092 void TrailTracking_Start();
00093 int TrailTracking_Advance();
00094 std::list<Trail> mlTrails;
00095 KeyFrame mFirstKF;
00096 KeyFrame mPreviousFrameKF;
00097 SE3<> KFZeroDesiredCamFromWorld;
00098
00099
00100 void TrackMap();
00101 void AssessTrackingQuality();
00102 void ApplyMotionModel();
00103 void UpdateMotionModel();
00104 int SearchForPoints(std::vector<TrackerData*> &vTD,
00105 int nRange,
00106 int nFineIts);
00107 Vector<6> CalcPoseUpdate(std::vector<TrackerData*> vTD,
00108 double dOverrideSigma = 0.0,
00109 bool bMarkOutliers = false);
00110 SE3<> mse3CamFromWorld;
00111 SE3<> mse3StartPos;
00112 Vector<6> mv6CameraVelocity;
00113 double mdVelocityMagnitude;
00114 double mdMSDScaledVelocityMagnitude;
00115 bool mbDidCoarse;
00116
00117 bool mbDraw;
00118
00119
00120 int mnFrame;
00121 int mnLastKeyFrameDropped;
00122 clock_t mnLastKeyFrameDroppedClock;
00123 void AddNewKeyFrame();
00124 SE3<> predictedCFromW;
00125
00126
00127
00128
00129 int manMeasAttempted[LEVELS];
00130 int manMeasFound[LEVELS];
00131 enum {BAD, DODGY, GOOD} mTrackingQuality;
00132 int mnLostFrames;
00133
00134
00135 bool AttemptRecovery();
00136 bool mbJustRecoveredSoUseCoarse;
00137 bool lastFrameLost;
00138 bool useGuess;
00139
00140
00141 SmallBlurryImage *mpSBILastFrame;
00142 SmallBlurryImage *mpSBIThisFrame;
00143 void CalcSBIRotation();
00144 Vector<6> mv6SBIRot;
00145 bool mbUseSBIInit;
00146
00147
00148 bool mbUserPressedSpacebar;
00149 std::ostringstream mMessageForUser;
00150
00151
00152 void GUICommandHandler(std::string sCommand, std::string sParams);
00153 static void GUICommandCallBack(void* ptr, std::string sCommand, std::string sParams);
00154 struct Command {std::string sCommand; std::string sParams; };
00155 std::vector<Command> mvQueuedCommands;
00156 };
00157
00158 #endif
00159
00160
00161
00162
00163
00164