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.
builtin_components.h
Go to the documentation of this file.
1 /*
2  This file is part of the CVD Library.
3 
4  Copyright (C) 2005 The Authors
5 
6  This library is free software; you can redistribute it and/or
7  modify it under the terms of the GNU Lesser General Public
8  License as published by the Free Software Foundation; either
9  version 2.1 of the License, or (at your option) any later version.
10 
11  This library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public
17  License along with this library; if not, write to the Free Software
18  Foundation, Inc.,
19  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21 #ifndef CVD_BUILTIN_TRAITS_H_
22 #define CVD_BUILTIN_TRAITS_H_
23 
24 #include <limits>
25 #include <cstddef>
26 
27 #include "TooN.h"
28 
29 namespace CVD
30 {
31  namespace Pixel
32  {
33 
34  //The "Component" class gives us information about the pixel components,
35  //ie how many components there are and whay the type is.
36 
37  //We use a 2 layer thing here so that Component is only properly defined
38  //for builtin types, unless explicitly overridden.
39 
40  template<class P, int spp> struct component_base {
41  template<bool x> struct component_base_only_for_basic_types;
43  };
44 
45  template<class P> struct component_base<P, 1>
46  {
47  };
48 
49  //template <class P, int primitive = std::numeric_limits<P>::is_specialized> struct Component;
50 
51  template<class P> struct Component
52  {
53  typedef P type;
54  static const size_t count = 1;
55 
56  static const P& get(const P& pixel, size_t)
57  {
58  return pixel;
59  }
60 
61  static P& get(P& pixel, size_t)
62  {
63  return pixel;
64  }
65 
66  };
67 
68  template<class P, int I> struct Component<P[I]>
69  {
70  typedef P type;
71  static const size_t count=I;
72 
73  static const P& get(const P pixel[I], size_t i)
74  {
75  return pixel[i];
76  }
77 
78  static inline P& get(P pixel[I], size_t i)
79  {
80  return pixel[i];
81  }
82  };
83 
84  template<int N> struct Component<TooN::Vector<N> >
85  {
86  typedef double type;
87  static const size_t count=N;
88 
89  static const type& get(const TooN::Vector<N>& pixel, size_t i)
90  {
91  return pixel[i];
92  }
93 
94  static inline type& get(TooN::Vector<N>& pixel, size_t i)
95  {
96  return pixel[i];
97  }
98  };
99 
100  template<int N, int M> struct Component<TooN::Matrix<N,M> >
101  {
102  typedef double type;
103  static const size_t count=N*M;
104 
105  static const type& get(const TooN::Matrix<N,M>& pixel, size_t i)
106  {
107  return pixel[i/M][i%M];
108  }
109 
110  static inline type& get(TooN::Matrix<N,M>& pixel, size_t i)
111  {
112  return pixel[i/M][i%M];
113  }
114  };
115 
116  }
117 }
118 
119 #endif
static const size_t count
Everything lives inside this namespace.
Definition: allocator.hh:48
Definition: abs.h:24