forked from jonazpiazu/PTAM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
KeyFrame.h
100 lines (81 loc) · 3.79 KB
/
KeyFrame.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
// -*- c++ -*-
// Copyright 2008 Isis Innovation Limited
//
// This header declares the data structures to do with keyframes:
// structs KeyFrame, Level, Measurement, Candidate.
//
// A KeyFrame contains an image pyramid stored as array of Level;
// A KeyFrame also has associated map-point mesurements stored as a vector of Measurment;
// Each individual Level contains an image, corner points, and special corner points
// which are promoted to Candidate status (the mapmaker tries to make new map points from those.)
//
// KeyFrames are stored in the Map class and manipulated by the MapMaker.
// However, the tracker also stores its current frame as a half-populated
// KeyFrame struct.
#ifndef __KEYFRAME_H
#define __KEYFRAME_H
#include <TooN/TooN.h>
using namespace TooN;
#include <TooN/se3.h>
#include <cvd/image.h>
#include <cvd/byte.h>
#include <vector>
#include <set>
#include <map>
class MapPoint;
class SmallBlurryImage;
#define LEVELS 4
// Candidate: a feature in an image which could be made into a map point
struct Candidate
{
CVD::ImageRef irLevelPos;
Vector<2> v2RootPos;
double dSTScore;
};
// Measurement: A 2D image measurement of a map point. Each keyframe stores a bunch of these.
struct Measurement
{
int nLevel; // Which image level?
bool bSubPix; // Has this measurement been refined to sub-pixel level?
Vector<2> v2RootPos; // Position of the measurement, REFERED TO PYRAMID LEVEL ZERO
enum {SRC_TRACKER, SRC_REFIND, SRC_ROOT, SRC_TRAIL, SRC_EPIPOLAR} Source; // Where has this measurement come frome?
};
// Each keyframe is made of LEVELS pyramid levels, stored in struct Level.
// This contains image data and corner points.
struct Level
{
inline Level()
{
bImplaneCornersCached = false;
};
CVD::Image<CVD::byte> im; // The pyramid level pixels
std::vector<CVD::ImageRef> vCorners; // All FAST corners on this level
std::vector<int> vCornerRowLUT; // Row-index into the FAST corners, speeds up access
std::vector<CVD::ImageRef> vMaxCorners; // The maximal FAST corners
Level& operator=(const Level &rhs);
std::vector<Candidate> vCandidates; // Potential locations of new map points
bool bImplaneCornersCached; // Also keep image-plane (z=1) positions of FAST corners to speed up epipolar search
std::vector<Vector<2> > vImplaneCorners; // Corner points un-projected into z=1-plane coordinates
};
// The actual KeyFrame struct. The map contains of a bunch of these. However, the tracker uses this
// struct as well: every incoming frame is turned into a keyframe before tracking; most of these
// are then simply discarded, but sometimes they're then just added to the map.
struct KeyFrame
{
inline KeyFrame()
{
pSBI = NULL;
}
SE3<> se3CfromW; // The coordinate frame of this key-frame as a Camera-From-World transformation
bool bFixed; // Is the coordinate frame of this keyframe fixed? (only true for first KF!)
Level aLevels[LEVELS]; // Images, corners, etc lives in this array of pyramid levels
std::map<MapPoint*, Measurement> mMeasurements; // All the measurements associated with the keyframe
void MakeKeyFrame_Lite(CVD::BasicImage<CVD::byte> &im); // This takes an image and calculates pyramid levels etc to fill the
// keyframe data structures with everything that's needed by the tracker..
void MakeKeyFrame_Rest(); // ... while this calculates the rest of the data which the mapmaker needs.
double dSceneDepthMean; // Hacky hueristics to improve epipolar search.
double dSceneDepthSigma;
SmallBlurryImage *pSBI; // The relocaliser uses this
};
typedef std::map<MapPoint*, Measurement>::iterator meas_it; // For convenience, and to work around an emacs paren-matching bug
#endif