Visual Servoing Platform
version 3.7.0
Toggle main menu visibility
Loading...
Searching...
No Matches
vpColorGetter.h
1
/*
2
* ViSP, open source Visual Servoing Platform software.
3
* Copyright (C) 2005 - 2024 by Inria. All rights reserved.
4
*
5
* This software is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
9
* See the file LICENSE.txt at the root directory of this source
10
* distribution for additional information about the GNU GPL.
11
*
12
* For using ViSP with software that can not be combined with the GNU
13
* GPL, please contact Inria about acquiring a ViSP Professional
14
* Edition License.
15
*
16
* See https://visp.inria.fr for more information.
17
*
18
* This software was developed at:
19
* Inria Rennes - Bretagne Atlantique
20
* Campus Universitaire de Beaulieu
21
* 35042 Rennes Cedex
22
* France
23
*
24
* If you have questions regarding the use of this file, please contact
25
* Inria at visp@inria.fr
26
*
27
* This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
28
* WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
29
*
30
* Description:
31
* Color getter.
32
*/
33
34
#ifndef VP_COLOR_GETTER_H
35
#define VP_COLOR_GETTER_H
36
37
#include <visp3/core/vpConfig.h>
38
#include <visp3/core/vpHSV.h>
39
#include <visp3/core/vpRGBa.h>
40
41
BEGIN_VISP_NAMESPACE
47
template
<
int
ID>
48
class
vpColorGetter
49
{
50
public
:
51
#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
61
template
<
typename
ArithmeticType,
bool
useFullScale >
62
static
ArithmeticType &
get
(
vpHSV<ArithmeticType, useFullScale>
&col);
63
73
template
<
typename
ArithmeticType,
bool
useFullScale >
74
static
const
ArithmeticType &
get
(
const
vpHSV<ArithmeticType, useFullScale>
&col);
75
#endif
76
83
static
unsigned
char
&
get
(
vpRGBa
&col);
84
91
static
const
unsigned
char
&
get
(
const
vpRGBa
&col);
92
};
93
94
#if (VISP_CXX_STANDARD >= VISP_CXX_STANDARD_11)
95
template
<>
96
template
<
typename
ArithmeticType,
bool
useFullScale>
97
inline
ArithmeticType &
vpColorGetter<0>::get
(
vpHSV<ArithmeticType, useFullScale>
&hsv)
98
{
99
return
hsv.
H
;
100
}
101
102
template
<>
103
template
<
typename
ArithmeticType,
bool
useFullScale>
104
inline
ArithmeticType &
vpColorGetter<1>::get
(
vpHSV<ArithmeticType, useFullScale>
&hsv)
105
{
106
return
hsv.
S
;
107
}
108
109
template
<>
110
template
<
typename
ArithmeticType,
bool
useFullScale>
111
inline
ArithmeticType &
vpColorGetter<2>::get
(
vpHSV<ArithmeticType, useFullScale>
&hsv)
112
{
113
return
hsv.
V
;
114
}
115
116
template
<>
117
template
<
typename
ArithmeticType,
bool
useFullScale>
118
inline
const
ArithmeticType &
vpColorGetter<0>::get
(
const
vpHSV<ArithmeticType, useFullScale>
&hsv)
119
{
120
return
hsv.
H
;
121
}
122
123
template
<>
124
template
<
typename
ArithmeticType,
bool
useFullScale>
125
inline
const
ArithmeticType &
vpColorGetter<1>::get
(
const
vpHSV<ArithmeticType, useFullScale>
&hsv)
126
{
127
return
hsv.
S
;
128
}
129
130
template
<>
131
template
<
typename
ArithmeticType,
bool
useFullScale>
132
inline
const
ArithmeticType &
vpColorGetter<2>::get
(
const
vpHSV<ArithmeticType, useFullScale>
&hsv)
133
{
134
return
hsv.
V
;
135
}
136
#endif
137
138
template
<>
139
inline
unsigned
char
&
vpColorGetter<0>::get
(
vpRGBa
&rgba)
140
{
141
return
rgba.
R
;
142
}
143
144
template
<>
145
inline
unsigned
char
&
vpColorGetter<1>::get
(
vpRGBa
&rgba)
146
{
147
return
rgba.
G
;
148
}
149
150
template
<>
151
inline
unsigned
char
&
vpColorGetter<2>::get
(
vpRGBa
&rgba)
152
{
153
return
rgba.
B
;
154
}
155
156
template
<>
157
inline
unsigned
char
&
vpColorGetter<3>::get
(
vpRGBa
&rgba)
158
{
159
return
rgba.
A
;
160
}
161
162
template
<>
163
inline
const
unsigned
char
&
vpColorGetter<0>::get
(
const
vpRGBa
&rgba)
164
{
165
return
rgba.
R
;
166
}
167
168
template
<>
169
inline
const
unsigned
char
&
vpColorGetter<1>::get
(
const
vpRGBa
&rgba)
170
{
171
return
rgba.
G
;
172
}
173
174
template
<>
175
inline
const
unsigned
char
&
vpColorGetter<2>::get
(
const
vpRGBa
&rgba)
176
{
177
return
rgba.
B
;
178
}
179
180
template
<>
181
inline
const
unsigned
char
&
vpColorGetter<3>::get
(
const
vpRGBa
&rgba)
182
{
183
return
rgba.
A
;
184
}
185
END_VISP_NAMESPACE
186
#endif
vpColorGetter
Helper class that permits to get a channel of a color type by its index instead of its name.
Definition
vpColorGetter.h:49
vpColorGetter::get
static const unsigned char & get(const vpRGBa &col)
Getter for a vpRGBA pixel.
vpColorGetter::get
static ArithmeticType & get(vpHSV< ArithmeticType, useFullScale > &col)
Setter for a channel of a HSV pixel.
vpColorGetter::get
static unsigned char & get(vpRGBa &col)
Setter for a vpRGBa pixel.
vpColorGetter::get
static const ArithmeticType & get(const vpHSV< ArithmeticType, useFullScale > &col)
Getter for a channel of a HSV pixel.
vpHSV
Class implementing the HSV pixel format.
Definition
vpHSV.h:135
vpHSV::V
T V
Definition
vpHSV.h:539
vpHSV::S
T S
Definition
vpHSV.h:538
vpHSV::H
T H
Definition
vpHSV.h:537
vpRGBa
Definition
vpRGBa.h:74
vpRGBa::B
unsigned char B
Blue component.
Definition
vpRGBa.h:327
vpRGBa::R
unsigned char R
Red component.
Definition
vpRGBa.h:325
vpRGBa::G
unsigned char G
Green component.
Definition
vpRGBa.h:326
vpRGBa::A
unsigned char A
Additional component.
Definition
vpRGBa.h:328
BEGIN_VISP_NAMESPACE
Definition
vpMbtDistanceCircle.cpp:55
modules
core
include
visp3
core
vpColorGetter.h
Generated by
1.17.0