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.
pixel_traits.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_PIXEL_TRAITS_H_
22 #define CVD_PIXEL_TRAITS_H_
23 
24 #include <limits>
25 #include "TooN.h"
26 
27 
28 namespace CVD {
29 namespace Pixel {
30 
31  //This is required for MIPSPro, since it is able to deduce more than gcc 3.3
32  //before a template is instantiated
33  template<class T> struct traits_error
34  {
35  };
36 
37  // LIFT is a dummy parameter to lift the partial specialisations of traits
38  // on various types into templates again. Then the visibility of static const
39  // members is sorted out by the compiler correctly.
40  template<class T, int LIFT=0> struct traits: public traits_error<T>
41  {
43  };
44 
45  template<int LIFT> struct traits<unsigned char, LIFT>
46  {
47  typedef int wider_type;
48  typedef float float_type;
49  static const bool integral = true;
50  static const bool is_signed = false;
51  static const int bits_used = 8;
52  static const unsigned char max_intensity=(1 << bits_used) - 1;
53  };
54 
55  template<int LIFT> struct traits<char, LIFT>
56  {
57  typedef int wider_type;
58  typedef float float_type;
59  static const bool integral = true;
60  static const bool is_signed = std::numeric_limits<char>::is_signed;
61  static const int bits_used = std::numeric_limits<char>::digits;
62  static const char max_intensity=(1 << bits_used) - 1;
63  };
64 
65  template<int LIFT> struct traits<signed char, LIFT>
66  {
67  typedef int wider_type;
68  typedef float float_type;
69  static const bool integral = true;
70  static const bool is_signed = false;
71  static const int bits_used = 7;
72  static const signed char max_intensity=(1 << bits_used) - 1;
73  };
74 
75  template<int LIFT> struct traits<short, LIFT>
76  {
77  typedef int wider_type;
78  typedef float float_type;
79  static const bool integral = true;
80  static const bool is_signed = true;
81  static const int bits_used = 15;
82  static const short max_intensity=(1 << bits_used) - 1;
83  };
84 
85  template<int LIFT> struct traits<unsigned short, LIFT>
86  {
87  typedef int wider_type;
88  typedef float float_type;
89  static const bool integral = true;
90  static const bool is_signed = false;
91  static const int bits_used = 16;
92  static const unsigned short max_intensity=(1 << bits_used) - 1;
93  };
94 
95  template<int LIFT> struct traits<int, LIFT>
96  {
97  typedef int wider_type;
98  typedef float float_type;
99  static const bool integral = true;
100  static const bool is_signed = true;
101  static const int bits_used = 16;
102  static const int max_intensity=(1 << bits_used) - 1;
103  };
104 
105  template<int LIFT> struct traits<unsigned int, LIFT>
106  {
107  typedef unsigned int wider_type;
108  typedef float float_type;
109  static const bool integral = true;
110  static const bool is_signed = false;
111  static const int bits_used = 16;
112  static const unsigned int max_intensity=(1 << bits_used) - 1;
113  };
114 
115  template<int LIFT> struct traits<long, LIFT>
116  {
117  typedef int wider_type;
118  typedef float float_type;
119  static const bool integral = true;
120  static const bool is_signed = true;
121  static const int bits_used = 16;
122  static const long max_intensity=(1 << bits_used) - 1;
123  };
124 
125  template<int LIFT> struct traits<long long, LIFT>
126  {
127  typedef long long wider_type;
128  typedef double float_type;
129  static const bool integral = true;
130  static const bool is_signed = true;
131  static const int bits_used = 31;
132  static const long long max_intensity=(1ll << bits_used) - 1ll;
133  };
134 
135  template<int LIFT> struct traits<unsigned long long, LIFT>
136  {
137  typedef unsigned long long wider_type;
138  typedef double float_type;
139  static const bool integral = true;
140  static const bool is_signed = false;
141  static const int bits_used = 31;
142  static const unsigned long long max_intensity=(1ull << bits_used) - 1ull;
143  };
144 
145  template<int LIFT> struct traits<unsigned long, LIFT>
146  {
147  typedef unsigned int wider_type;
148  typedef float float_type;
149  static const bool integral = true;
150  static const bool is_signed = false;
151  static const int bits_used = 16;
152  static const long max_intensity=(1 << bits_used) - 1;
153  };
154 
155  template<int LIFT> struct traits<float, LIFT>
156  {
157  typedef float wider_type;
158  typedef float float_type;
159  static const bool integral = false;
160  static const bool is_signed = true;
161  static const float max_intensity;
162  };
163 
164  template<int LIFT> const float traits<float, LIFT>::max_intensity = 1.0f;
165 
166  template<int LIFT> struct traits<double, LIFT>
167  {
168  typedef double wider_type;
169  typedef double float_type;
170  static const bool integral = false;
171  static const bool is_signed = true;
172  static const double max_intensity;
173  };
174 
175  template<int LIFT> const double traits<double, LIFT>::max_intensity = 1.0;
176 
177  template<int LIFT> struct traits<long double, LIFT>
178  {
179  typedef long double wider_type;
180  typedef long double float_type;
181  static const bool integral = false;
182  static const bool is_signed = true;
183  static const long double max_intensity;
184  };
185 
186  template<int LIFT> struct traits<bool, LIFT>
187  {
188  typedef int wider_type; // int holds a sum of many bools
189  typedef float float_type; // which floating point type can hold them?
190  static const bool integral = true; // bool is integral
191  static const bool is_signed = false; // bool is unsigned
192  static const int bits_used = 1; // only one bit
193  static const bool max_intensity= true; // the 'high' value
194  };
195 
196 
197 #if defined (CVD_HAVE_TOON)
198  template<int N> struct traits<TooN::Vector<N> >
199  {
200  typedef TooN::Vector<N> wider_type;
201  typedef TooN::Vector<N> float_type;
202  static const bool integral = false;
203  static const bool is_signed = true;
204  static const TooN::Vector<N> max_intensity;
205  };
206  template <int N> const TooN::Vector<N> traits<TooN::Vector<N> >::max_intensity = TooN::Vector<N>(1.0);
207 
208  template<int N, int M> struct traits<TooN::Matrix<N,M> >
209  {
210  typedef TooN::Matrix<N,M> wider_type;
211  typedef TooN::Matrix<N,M> float_type;
212  static const bool integral = false;
213  static const bool is_signed = true;
214  };
215 
216 #endif
217 
218 
219  template<int LIFT> const long double traits<long double, LIFT>::max_intensity = 1.0;
220 
221  template<class C> struct indirect_type
222  {
223  typedef C type;
224  };
225 
226  template<class C, int N, int LIFT> struct traits<C[N], LIFT>
227  {
230  };
231 }
232 }
233 
234 #endif
static const long double max_intensity
Definition: pixel_traits.h:183
Everything lives inside this namespace.
Definition: allocator.hh:48
indirect_type< typename traits< C >::float_type[N]>::type float_type
Definition: pixel_traits.h:229
static const double max_intensity
Definition: pixel_traits.h:172
Definition: abs.h:24
static const float max_intensity
Definition: pixel_traits.h:161
static const bool integral
Definition: pixel_traits.h:42
indirect_type< typename traits< C >::wider_type[N]>::type wider_type
Definition: pixel_traits.h:228