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 "ptam/Params.h"
00029
00030 #include <sstream>
00031 #include <vector>
00032 #include <list>
00033
00034 struct TrackerData;
00035 struct Trail
00036 {
00037 MiniPatch mPatch;
00038 CVD::ImageRef irCurrentPos;
00039 CVD::ImageRef irInitialPos;
00040 };
00041
00042 class Tracker
00043 {
00044 public:
00045 Tracker(CVD::ImageRef irVideoSize, const ATANCamera &c, Map &m, MapMaker &mm);
00046
00047
00048 void TrackFrame(CVD::Image<CVD::byte> &imFrame, bool bDraw);
00049 void TrackFrame(CVD::Image<CVD::byte> &imFrame, bool bDraw, const TooN::SO3<double> & imuOrientation);
00050
00051 inline SE3<> GetCurrentPose() { return mse3CamFromWorld;}
00052
00053 inline Matrix<6> GetCurrentCov() { return mmCovariances;}
00054 inline KeyFrame::Ptr GetCurrentKF() { return mCurrentKF;}
00055 Vector<3> CalcSBIRotation(SmallBlurryImage *SBI1, SmallBlurryImage *SBI2);
00056
00057
00058 std::string GetMessageForUser();
00059 int getTrackingQuality(){return mTrackingQuality;}
00060
00061 void command(const std::string & params);
00062 std::list<Trail> & getTrails(){return mlTrails;};
00063 bool getTrailTrackingStarted(){return mnInitialStage == TRAIL_TRACKING_STARTED;};
00064 bool getTrailTrackingComplete(){return mnInitialStage == TRAIL_TRACKING_COMPLETE;};
00065 CVD::Image<TooN::Vector<2> > & ComputeGrid();
00066
00067 protected:
00068 CVD::Image<TooN::Vector<2> > mProjVertices;
00069 KeyFrame::Ptr mCurrentKF;
00070
00071
00072 Map &mMap;
00073 MapMaker &mMapMaker;
00074 ATANCamera mCamera;
00075 Relocaliser mRelocaliser;
00076
00077 CVD::ImageRef mirSize;
00078
00079 void Reset();
00080 void RenderGrid();
00081
00082
00083 void TrackForInitialMap();
00084 enum {TRAIL_TRACKING_NOT_STARTED,
00085 TRAIL_TRACKING_STARTED,
00086 TRAIL_TRACKING_COMPLETE} mnInitialStage;
00087 void TrailTracking_Start();
00088 int TrailTracking_Advance();
00089 std::list<Trail> mlTrails;
00090 KeyFrame::Ptr mFirstKF;
00091 KeyFrame::Ptr mPreviousFrameKF;
00092
00093
00094 void TrackMap();
00095 void AssessTrackingQuality();
00096 void ApplyMotionModel();
00097 void UpdateMotionModel();
00098 int SearchForPoints(std::vector<TrackerData*> &vTD,
00099 int nRange,
00100 int nFineIts);
00101 Vector<6> CalcPoseUpdate(std::vector<TrackerData*> vTD,
00102 double dOverrideSigma = 0.0,
00103 bool bMarkOutliers = false);
00104 SE3<> mse3CamFromWorld;
00105 SE3<> mse3StartPos;
00106 Vector<6> mv6CameraVelocity;
00107 double mdVelocityMagnitude;
00108 double mdMSDScaledVelocityMagnitude;
00109 bool mbDidCoarse;
00110
00111 bool mbDraw;
00112
00113
00114 SO3<> mso3CurrentImu;
00115 SO3<> mso3LastImu;
00116
00117
00118
00119
00120
00121 Matrix<6> mmCovariances;
00122 KeyFrame::Ptr mOldKF;
00123 bool mAutoreset;
00124
00125
00126
00127 int mnFrame;
00128 int mnLastKeyFrameDropped;
00129 void AddNewKeyFrame();
00130
00131
00132 int manMeasAttempted[LEVELS];
00133 int manMeasFound[LEVELS];
00134 enum {BAD, DODGY, GOOD} mTrackingQuality;
00135 int mnLostFrames;
00136
00137
00138 bool AttemptRecovery();
00139 bool mbJustRecoveredSoUseCoarse;
00140
00141
00142 SmallBlurryImage *mpSBILastFrame;
00143 SmallBlurryImage *mpSBIThisFrame;
00144 void CalcSBIRotation();
00145 Vector<6> mv6SBIRot;
00146 bool mbUseSBIInit;
00147
00148
00149 bool mbUserPressedSpacebar;
00150 std::ostringstream mMessageForUser;
00151
00152
00153 void GUICommandHandler(std::string sCommand, std::string sParams);
00154 static void GUICommandCallBack(void* ptr, std::string sCommand, std::string sParams);
00155 struct Command {std::string sCommand; std::string sParams; };
00156 std::vector<Command> mvQueuedCommands;
00157
00158
00159 };
00160
00161 #endif
00162
00163
00164
00165
00166
00167