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.
LevelHelpers.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 // Copyright 2008 Isis Innovation Limited
3 
4 // LevelHelpers.h - a few handy tools to ease using levels.
5 // The important thing is the XXXPos functions, which convert
6 // image positions from one level to another. Use these whenever
7 // transforming positions to ensure consistent operation!!
8 
9 #ifndef __LEVEL_HELPERS_H
10 #define __LEVEL_HELPERS_H
11 #include "TooN.h"
12 using namespace TooN;
13 #include "image_ref.h"
14 
15 // Set of global colours useful for drawing stuff:
17 // (These are filled in in KeyFrame.cc)
18 
19 // What is the scale of a level?
20 inline int LevelScale(int nLevel)
21 {
22  return 1 << nLevel;
23 }
24 
25 // 1-D transform to level zero:
26 inline double LevelZeroPos(double dLevelPos, int nLevel)
27 {
28  return (dLevelPos + 0.5) * LevelScale(nLevel) - 0.5;
29 }
30 
31 // 2-D transforms to level zero:
32 inline Vector<2> LevelZeroPos(Vector<2> v2LevelPos, int nLevel)
33 {
34  Vector<2> v2Ans;
35  v2Ans[0] = LevelZeroPos(v2LevelPos[0], nLevel);
36  v2Ans[1] = LevelZeroPos(v2LevelPos[1], nLevel);
37  return v2Ans;
38 }
39 inline Vector<2> LevelZeroPos(CVD::ImageRef irLevelPos, int nLevel)
40 {
41  Vector<2> v2Ans;
42  v2Ans[0] = LevelZeroPos(irLevelPos.x, nLevel);
43  v2Ans[1] = LevelZeroPos(irLevelPos.y, nLevel);
44  return v2Ans;
45 }
46 
47 // 1-D transform from level zero to level N:
48 inline double LevelNPos(double dRootPos, int nLevel)
49 {
50  return (dRootPos + 0.5) / LevelScale(nLevel) - 0.5;
51 }
52 
53 // 2-D transform from level zero to level N:
54 inline Vector<2> LevelNPos(Vector<2> v2RootPos, int nLevel)
55 {
56  Vector<2> v2Ans;
57  v2Ans[0] = LevelNPos(v2RootPos[0], nLevel);
58  v2Ans[1] = LevelNPos(v2RootPos[1], nLevel);
59  return v2Ans;
60 }
61 
62 #endif
int y
The y co-ordinate.
Definition: image_ref.h:180
int x
The x co-ordinate.
Definition: image_ref.h:179
int LevelScale(int nLevel)
Definition: LevelHelpers.h:20
double LevelNPos(double dRootPos, int nLevel)
Definition: LevelHelpers.h:48
Vector< 3, float > gavLevelColors[]
Definition: KeyFrame.cpp:122
Everything lives inside this namespace.
Definition: allocator.hh:48
double LevelZeroPos(double dLevelPos, int nLevel)
Definition: LevelHelpers.h:26