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.
reference.hh
Go to the documentation of this file.
1 // -*- c++ -*-
2 
3 // Copyright (C) 2009 Tom Drummond (twd20@cam.ac.uk),
4 // Ed Rosten (er258@cam.ac.uk)
5 //
6 // This file is part of the TooN Library. This library is free
7 // software; you can redistribute it and/or modify it under the
8 // terms of the GNU General Public License as published by the
9 // Free Software Foundation; either version 2, or (at your option)
10 // any later version.
11 
12 // This library is distributed in the hope that it will be useful,
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 // GNU General Public License for more details.
16 
17 // You should have received a copy of the GNU General Public License along
18 // with this library; see the file COPYING. If not, write to the Free
19 // Software Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
20 // USA.
21 
22 // As a special exception, you may use this file as part of a free software
23 // library without restriction. Specifically, if other files instantiate
24 // templates or use macros or inline functions from this file, or you compile
25 // this file and link it with other files to produce an executable, this
26 // file does not by itself cause the resulting executable to be covered by
27 // the GNU General Public License. This exception does not however
28 // invalidate any other reasons why the executable file might be covered by
29 // the GNU General Public License.
30 
31 namespace TooN {
32 
34 //
35 // Helper classes for matrices constructed as references to foreign data
36 //
37 
38 struct Reference
39 {
40 
41  template<int Size, typename Precision>
42  struct VLayout
43  : public Internal::GenericVBase<Size, Precision, 1, Internal::VectorSlice<Size, Precision> >
44  {
45 
46  VLayout(Precision* p, int sz=0)
47  : Internal::GenericVBase<Size, Precision, 1, Internal::VectorSlice<Size, Precision> >(p, sz, 0)
48  {}
49  };
50 
51 
52  struct RowMajor
53  {
54  template<int Rows, int Cols, class Precision>
55  struct MLayout
56  : public Internal::GenericMBase<Rows, Cols, Precision, (Cols==-1?-2:Cols), 1, Internal::MatrixSlice<Rows, Cols, Precision> >
57  {
58 
59  MLayout(Precision* p)
60  : Internal::GenericMBase<Rows,Cols,Precision, (Cols==-1?-2:Cols), 1, Internal::MatrixSlice<Rows, Cols, Precision> > (p)
61  {}
62  MLayout(Precision* p, int r, int c)
63  : Internal::GenericMBase<Rows,Cols,Precision, (Cols==-1?-2:Cols), 1, Internal::MatrixSlice<Rows, Cols, Precision> > (p, r, c, 0, 0)
64  {}
65  };
66  };
67 
68  struct ColMajor
69  {
70  template<int Rows, int Cols, class Precision> struct MLayout: public Internal::GenericMBase<Rows, Cols, Precision, 1, (Rows==-1?-2:Rows), Internal::MatrixSlice<Rows, Cols, Precision> >
71  {
72  MLayout(Precision* p)
73  : Internal::GenericMBase<Rows, Cols, Precision, 1, (Rows==-1?-2:Rows), Internal::MatrixSlice<Rows, Cols, Precision> >(p)
74  {}
75  MLayout(Precision* p, int r, int c)
76  : Internal::GenericMBase<Rows, Cols, Precision, 1, (Rows==-1?-2:Rows), Internal::MatrixSlice<Rows, Cols, Precision> >(p, r, c, 0, 0)
77  {}
78  };
79  };
80 };
81 
82 
83  inline Vector<Dynamic, double, Reference> wrapVector(double* data, int size) { return Vector<Dynamic, double, Reference>(data, size); }
84  inline const Vector<Dynamic, const double, Reference> wrapVector(const double* data, int size) { return Vector<Dynamic, const double, Reference>(data, size); }
85 template<int Size> inline Vector<Size, double, Reference> wrapVector(double* data) { return Vector<Size, double, Reference>(data); }
86 template<int Size> inline const Vector<Size, const double, Reference> wrapVector(const double* data) { return Vector<Size, const double, Reference>(data); }
87 template<class Precision> inline Vector<Dynamic, Precision, Reference> wrapVector(Precision* data, int size) { return Vector<Dynamic, Precision, Reference>(data, size); }
88 template<class Precision> inline const Vector<Dynamic, const Precision, Reference> wrapVector(const Precision* data, int size) { return Vector<Dynamic, const Precision, Reference>(data, size); }
89 template<int Size, class Precision> inline Vector<Size, Precision, Reference> wrapVector(Precision* data) { return Vector<Size, Precision, Reference>(data); }
90 template<int Size, class Precision> inline const Vector<Size, const Precision, Reference> wrapVector(const Precision* data) { return Vector<Size, const Precision, Reference>(data); }
91 
97 //Fully static matrices, ie no size parameters
99 template<int Rows, int Cols> inline const Matrix<Rows, Cols, const double, Reference::RowMajor> wrapMatrix(const double* data) { return Matrix<Rows, Cols, const double, Reference::RowMajor>(data);}
100 template<int Rows, int Cols, class Precision> inline Matrix<Rows, Cols, Precision, Reference::RowMajor> wrapMatrix(Precision* data) { return Matrix<Rows, Cols, Precision, Reference::RowMajor>(data);}
101 template<int Rows, int Cols, class Precision> inline const Matrix<Rows, Cols, const Precision, Reference::RowMajor> wrapMatrix(const Precision* data) { return Matrix<Rows, Cols, const Precision, Reference::RowMajor>(data);}
102 //Static sizes with size parameters (useful for half-dynamic matrices)
103 template<int Rows, int Cols> inline Matrix<Rows, Cols, double, Reference::RowMajor> wrapMatrix(double* data, int rows, int cols) { return Matrix<Rows, Cols, double, Reference::RowMajor>(data, rows, cols);}
104 template<int Rows, int Cols> inline const Matrix<Rows, Cols, const double, Reference::RowMajor> wrapMatrix(const double* data, int rows, int cols) { return Matrix<Rows, Cols, const double, Reference::RowMajor>(data, rows, cols);}
105 template<int Rows, int Cols, class Precision> inline Matrix<Rows, Cols, Precision, Reference::RowMajor> wrapMatrix(Precision* data, int rows, int cols) { return Matrix<Rows, Cols, Precision, Reference::RowMajor>(data, rows, cols);}
106 template<int Rows, int Cols, class Precision> inline const Matrix<Rows, Cols, const Precision, Reference::RowMajor> wrapMatrix(const Precision* data, int rows, int cols) { return Matrix<Rows, Cols, const Precision, Reference::RowMajor>(data, rows, cols);}
107 //Fully dynamic
108  inline Matrix<Dynamic, Dynamic, double, Reference::RowMajor> wrapMatrix(double* data, int rows, int cols) { return Matrix<Dynamic, Dynamic, double, Reference::RowMajor>(data, rows, cols);}
109  inline const Matrix<Dynamic, Dynamic, const double, Reference::RowMajor> wrapMatrix(const double* data, int rows, int cols) { return Matrix<Dynamic, Dynamic, const double, Reference::RowMajor>(data, rows, cols);}
110 template<class Precision> inline Matrix<Dynamic, Dynamic, Precision, Reference::RowMajor> wrapMatrix(Precision* data, int rows, int cols) { return Matrix<Dynamic, Dynamic, Precision, Reference::RowMajor>(data, rows, cols);}
111 template<class Precision> inline const Matrix<Dynamic, Dynamic, const Precision, Reference::RowMajor> wrapMatrix(const Precision* data, int rows, int cols) { return Matrix<Dynamic, Dynamic, const Precision, Reference::RowMajor>(data, rows, cols);}
113 }
MLayout(Precision *p, int r, int c)
Definition: reference.hh:62
MLayout(Precision *p, int r, int c)
Definition: reference.hh:75
Matrix< Rows, Cols, double, Reference::RowMajor > wrapMatrix(double *data)
Definition: reference.hh:98
Vector< Dynamic, double, Reference > wrapVector(double *data, int size)
Definition: reference.hh:83
Everything lives inside this namespace.
Definition: allocator.hh:48
VLayout(Precision *p, int sz=0)
Definition: reference.hh:46