SLAMflex SE  0.1.0
SLAMflex provides detection and tracking of dominant planes for smartphone devices. This plane can then be used to show AR content relative to the plane orientation. The detection of plane is performed in the field of view of the smartphone camera. In subsequent frames it is tracked. The interface returns the plane position and orientation.
Relocaliser.cpp
Go to the documentation of this file.
1 // Copyright 2008 Isis Innovation Limited
2 #include "Relocaliser.h"
3 #include "SmallBlurryImage.h"
4 #include "utility.h"
5 
6 using namespace CVD;
7 using namespace std;
8 
10  : mMap(map),
11  mCamera(camera)
12 {
13 };
14 
16 {
17  return mse3Best;
18 }
19 
21 {
22  // Ensure the incoming frame has a SmallBlurryImage attached
23  if(!kCurrent.pSBI)
24  kCurrent.pSBI = new SmallBlurryImage(kCurrent);
25  else
26  kCurrent.pSBI->MakeFromKF(kCurrent);
27 
28  // Find the best ZMSSD match from all keyframes in map
29  ScoreKFs(kCurrent);
30 
31  // And estimate a camera rotation from a 3DOF image alignment
32  pair<SE2<>, double> result_pair = kCurrent.pSBI->IteratePosRelToTarget(*mMap.vpKeyFrames[mnBest]->pSBI, 6);
33  mse2 = result_pair.first;
34  double dScore =result_pair.second;
35 
36  SE3<> se3KeyFramePos = mMap.vpKeyFrames[mnBest]->se3CfromW;
38 
39  if(dScore < Reloc2MaxScore)
40  return true;
41  else
42  return false;
43 };
44 
45 // Compare current KF to all KFs stored in map by
46 // Zero-mean SSD
48 {
49  mdBestScore = 99999999999999.9;
50  mnBest = -1;
51 
52  for(unsigned int i=0; i<mMap.vpKeyFrames.size(); i++)
53  {
54  double dSSD = kCurrent.pSBI->ZMSSD(*mMap.vpKeyFrames[i]->pSBI);
55  if(dSSD < mdBestScore)
56  {
57  mdBestScore = dSSD;
58  mnBest = i;
59  }
60  }
61 }
62 
SmallBlurryImage * pSBI
Definition: KeyFrame.h:94
ATANCamera mCamera
Definition: Relocaliser.h:31
std::pair< SE2<>, double > IteratePosRelToTarget(SmallBlurryImage &other, int nIterations=10)
void MakeFromKF(KeyFrame &kf, double dBlur=2.5)
Map & mMap
Definition: Relocaliser.h:30
Definition: abs.h:24
const double Reloc2MaxScore
Definition: globals.h:18
Definition: se3.h:50
void ScoreKFs(KeyFrame &kCurrentF)
Definition: Relocaliser.cpp:47
std::vector< KeyFrame * > vpKeyFrames
Definition: Map.h:35
double mdBestScore
Definition: Relocaliser.h:33
Definition: Map.h:24
bool AttemptRecovery(KeyFrame &k)
Definition: Relocaliser.cpp:20
double ZMSSD(SmallBlurryImage &other)
Relocaliser(Map &map, ATANCamera &camera)
Definition: Relocaliser.cpp:9
SE3 BestPose()
Definition: Relocaliser.cpp:15
static SE3 SE3fromSE2(SE2<> se2, ATANCamera camera)