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.
rgb.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 */
22 // //
23 // rgb.h //
24 // //
25 // Contains definitions of Rgb template class //
26 // //
27 // derived from IPRS_* developed by Tom Drummond //
28 // //
30 #ifndef CVD_RGB_H
31 #define CVD_RGB_H
32 
33 #include <iostream>
34 
35 #include "byte.h"
36 #include "is_pod.h"
37 
38 namespace CVD {
39 
44 template <class T>
45 class Rgb
46 {
47 public:
49  Rgb() {}
54  inline Rgb(T r, T g, T b) : red(r),green(g),blue(b) {}
55  template <class S> inline explicit Rgb(const Rgb<S>& rgb) : red(static_cast<T>(rgb.red)), green(static_cast<T>(rgb.green)), blue(static_cast<T>(rgb.blue)) {}
56 
57  T red;
58  T green;
59  T blue;
60 
63  inline Rgb<T>& operator=(const Rgb<T>& c)
64  {red = c.red; green = c.green; blue = c.blue; return *this;}
65 
68  inline bool operator==(const Rgb<T>& c) const
69  {return red == c.red && green == c.green && blue == c.blue;}
70 
73  inline bool operator!=(const Rgb<T>& c) const
74  {return red != c.red || green != c.green || blue != c.blue;}
75 
78  template <class T2>
79  inline Rgb<T>& operator=(const Rgb<T2>& c){ red = c.red; green=c.green; blue=c.blue; return *this;}
80 
81  // T to_grey() {return 0.3*red + 0.6*green + 0.1*blue;}
82 };
83 
88 template <class T>
89 std::ostream& operator <<(std::ostream& os, const Rgb<T>& x)
90 {
91  return os << "(" << x.red << "," << x.green << ","
92  << x.blue << ")";
93 }
94 
99 inline std::ostream& operator <<(std::ostream& os, const Rgb<char>& x)
100 {
101  return os << "(" << (int)(unsigned char)x.red << ","
102  << (int)(unsigned char)x.green << ","
103  << (int)(unsigned char)x.blue << ")";
104 }
105 
110 inline std::ostream& operator <<(std::ostream& os, const Rgb<byte>& x)
111 {
112  return os << "(" << static_cast<int>(x.red) << ","
113  << static_cast<int>(x.green) << ","
114  << static_cast<int>(x.blue) << ")";
115 }
116 
117 
118 namespace Internal
119 {
120  template<class C> struct is_POD<Rgb<C> >
121  {
123  };
124 }
125 
126 
127 } // end namespace
128 #endif
T red
The red component.
Definition: rgb.h:57
Definition: rgb.h:45
Definition: abs.h:24
Rgb()
Default constructor. Does nothing.
Definition: rgb.h:49
T blue
The blue component.
Definition: rgb.h:59
Rgb< T > & operator=(const Rgb< T > &c)
Definition: rgb.h:63
Rgb(T r, T g, T b)
Definition: rgb.h:54
T green
The green component.
Definition: rgb.h:58
Rgb(const Rgb< S > &rgb)
Definition: rgb.h:55
Rgb< T > & operator=(const Rgb< T2 > &c)
Definition: rgb.h:79
bool operator==(const Rgb< T > &c) const
Definition: rgb.h:68
bool operator!=(const Rgb< T > &c) const
Definition: rgb.h:73