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.
rgba.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_RGBA_H
22 #define CVD_RGBA_H
23 
24 #include <iostream>
25 #include "is_pod.h"
26 
27 namespace CVD {
28 
29 
31 // CVD::Rgba
32 // Template class to represent red, green, blue and alpha components
33 //
37 template <typename T>
38 class Rgba
39 {
40 public:
42  Rgba() {}
48  Rgba(T r, T g, T b, T a) : red(r), green(g), blue(b), alpha(a) {}
49 
50  T red;
51  T green;
52  T blue;
53  T alpha;
54 
58  {red = c.red; green = c.green; blue = c.blue; alpha = c.alpha; return *this;}
59 
62  template <typename T2>
64  red = static_cast<T>(c.red);
65  green = static_cast<T>(c.green);
66  blue = static_cast<T>(c.blue);
67  alpha = static_cast<T>(c.alpha);
68  return *this;
69  }
70 
73  bool operator==(const Rgba<T>& c) const
74  {return red == c.red && green == c.green && blue == c.blue && alpha == c.alpha;}
75 
78  bool operator!=(const Rgba<T>& c) const
79  {return red != c.red || green != c.green || blue != c.blue || alpha != c.alpha;}
80 
81 // T to_grey() const {return 0.3*red + 0.6*green + 0.1*blue;}
82 };
83 
88 template <typename T>
89 std::ostream& operator <<(std::ostream& os, const Rgba<T>& x)
90 {
91  return os << "(" << x.red << "," << x.green << ","
92  << x.blue << "," << x.alpha << ")";
93 }
94 
99 inline std::ostream& operator <<(std::ostream& os, const Rgba<unsigned char>& x)
100 {
101  return os << "(" << static_cast<unsigned int>(x.red) << ","
102  << static_cast<unsigned int>(x.green) << ","
103  << static_cast<unsigned int>(x.blue) << ","
104  << static_cast<unsigned int>(x.alpha) << ")";
105 }
106 
107 namespace Internal
108 {
109  template<class C> struct is_POD<Rgba<C> >
110  {
112  };
113 }
114 
115 
116 } // end namespace
117 #endif
118 
Rgba< T > & operator=(const Rgba< T2 > &c)
Definition: rgba.h:63
Definition: rgba.h:38
T green
The green component.
Definition: rgba.h:51
Definition: abs.h:24
bool operator!=(const Rgba< T > &c) const
Definition: rgba.h:78
Rgba(T r, T g, T b, T a)
Definition: rgba.h:48
Rgba< T > & operator=(const Rgba< T > &c)
Definition: rgba.h:57
T red
The red component.
Definition: rgba.h:50
T alpha
The alpha component.
Definition: rgba.h:53
bool operator==(const Rgba< T > &c) const
Definition: rgba.h:73
Rgba()
Default constructor. Does nothing.
Definition: rgba.h:42
T blue
The blue component.
Definition: rgba.h:52