Relocaliser.cc
Go to the documentation of this file.
00001 // Copyright 2008 Isis Innovation Limited
00002 #include "Relocaliser.h"
00003 #include "SmallBlurryImage.h"
00004 #include <cvd/utility.h>
00005 #include <gvars3/instances.h>
00006 
00007 using namespace CVD;
00008 using namespace std;
00009 using namespace GVars3;
00010 
00011 Relocaliser::Relocaliser(Map &map, ATANCamera &camera)
00012   : mMap(map),
00013     mCamera(camera)
00014 {
00015 };
00016 
00017 SE3<> Relocaliser::BestPose()
00018 {
00019   return mse3Best;
00020 }
00021 
00022 bool Relocaliser::AttemptRecovery(KeyFrame &kCurrent)
00023 {
00024   // Ensure the incoming frame has a SmallBlurryImage attached
00025   if(!kCurrent.pSBI)
00026     kCurrent.pSBI = new SmallBlurryImage(kCurrent);
00027   else
00028     kCurrent.pSBI->MakeFromKF(kCurrent);
00029   
00030   // Find the best ZMSSD match from all keyframes in map
00031   ScoreKFs(kCurrent);
00032 
00033   // And estimate a camera rotation from a 3DOF image alignment
00034   pair<SE2<>, double> result_pair = kCurrent.pSBI->IteratePosRelToTarget(*mMap.vpKeyFrames[mnBest]->pSBI, 6);
00035   mse2 = result_pair.first;
00036   double dScore =result_pair.second;
00037   
00038   SE3<> se3KeyFramePos = mMap.vpKeyFrames[mnBest]->se3CfromW;
00039   mse3Best = SmallBlurryImage::SE3fromSE2(mse2, mCamera) * se3KeyFramePos;
00040   
00041   if(dScore < GV2.GetDouble("Reloc2.MaxScore", 9e6, SILENT))
00042     return true;
00043   else 
00044     return false;
00045 };
00046 
00047 // Compare current KF to all KFs stored in map by
00048 // Zero-mean SSD
00049 void Relocaliser::ScoreKFs(KeyFrame &kCurrent)
00050 {
00051   mdBestScore = 99999999999999.9;
00052   mnBest = -1;
00053   
00054   for(unsigned int i=0; i<mMap.vpKeyFrames.size(); i++)
00055     {
00056       double dSSD = kCurrent.pSBI->ZMSSD(*mMap.vpKeyFrames[i]->pSBI);
00057       if(dSSD < mdBestScore)
00058         {
00059           mdBestScore = dSSD;
00060           mnBest = i;
00061         }
00062     }
00063 }
00064 


tum_ardrone
Author(s):
autogenerated on Sat Jun 8 2019 20:27:23