image_encodings.h
Go to the documentation of this file.
1 #include "sick_scan/sick_scan_base.h" /* Base definitions included in all header files, added by add_sick_scan_base_header.py. Do not edit this line. */
2 
3 /*********************************************************************
4 * Software License Agreement (BSD License)
5 *
6 * Copyright (c) 2009, Willow Garage, Inc.
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 *
13 * * Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * * Redistributions in binary form must reproduce the above
16 * copyright notice, this list of conditions and the following
17 * disclaimer in the documentation and/or other materials provided
18 * with the distribution.
19 * * Neither the name of the Willow Garage nor the names of its
20 * contributors may be used to endorse or promote products derived
21 * from this software without specific prior written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
26 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
27 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
28 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
29 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
30 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
33 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34 * POSSIBILITY OF SUCH DAMAGE.
35 *********************************************************************/
36 
37 #ifndef SENSOR_MSGS_IMAGE_ENCODINGS_H
38 #define SENSOR_MSGS_IMAGE_ENCODINGS_H
39 
40 #include <stdexcept>
41 #include <string>
42 
43 namespace sensor_msgs
44 {
45  namespace image_encodings
46  {
47  const std::string RGB8 = "rgb8";
48  const std::string RGBA8 = "rgba8";
49  const std::string RGB16 = "rgb16";
50  const std::string RGBA16 = "rgba16";
51  const std::string BGR8 = "bgr8";
52  const std::string BGRA8 = "bgra8";
53  const std::string BGR16 = "bgr16";
54  const std::string BGRA16 = "bgra16";
55  const std::string MONO8="mono8";
56  const std::string MONO16="mono16";
57 
58  // OpenCV CvMat types
59  const std::string TYPE_8UC1="8UC1";
60  const std::string TYPE_8UC2="8UC2";
61  const std::string TYPE_8UC3="8UC3";
62  const std::string TYPE_8UC4="8UC4";
63  const std::string TYPE_8SC1="8SC1";
64  const std::string TYPE_8SC2="8SC2";
65  const std::string TYPE_8SC3="8SC3";
66  const std::string TYPE_8SC4="8SC4";
67  const std::string TYPE_16UC1="16UC1";
68  const std::string TYPE_16UC2="16UC2";
69  const std::string TYPE_16UC3="16UC3";
70  const std::string TYPE_16UC4="16UC4";
71  const std::string TYPE_16SC1="16SC1";
72  const std::string TYPE_16SC2="16SC2";
73  const std::string TYPE_16SC3="16SC3";
74  const std::string TYPE_16SC4="16SC4";
75  const std::string TYPE_32SC1="32SC1";
76  const std::string TYPE_32SC2="32SC2";
77  const std::string TYPE_32SC3="32SC3";
78  const std::string TYPE_32SC4="32SC4";
79  const std::string TYPE_32FC1="32FC1";
80  const std::string TYPE_32FC2="32FC2";
81  const std::string TYPE_32FC3="32FC3";
82  const std::string TYPE_32FC4="32FC4";
83  const std::string TYPE_64FC1="64FC1";
84  const std::string TYPE_64FC2="64FC2";
85  const std::string TYPE_64FC3="64FC3";
86  const std::string TYPE_64FC4="64FC4";
87 
88  // Bayer encodings
89  const std::string BAYER_RGGB8="bayer_rggb8";
90  const std::string BAYER_BGGR8="bayer_bggr8";
91  const std::string BAYER_GBRG8="bayer_gbrg8";
92  const std::string BAYER_GRBG8="bayer_grbg8";
93  const std::string BAYER_RGGB16="bayer_rggb16";
94  const std::string BAYER_BGGR16="bayer_bggr16";
95  const std::string BAYER_GBRG16="bayer_gbrg16";
96  const std::string BAYER_GRBG16="bayer_grbg16";
97 
98  // Miscellaneous
99  // This is the UYVY version of YUV422 codec http://www.fourcc.org/yuv.php#UYVY
100  // with an 8-bit depth
101  const std::string YUV422="yuv422";
102 
103  // Prefixes for abstract image encodings
104  const std::string ABSTRACT_ENCODING_PREFIXES[] = {
105  "8UC", "8SC", "16UC", "16SC", "32SC", "32FC", "64FC"};
106 
107  // Utility functions for inspecting an encoding string
108  static inline bool isColor(const std::string& encoding)
109  {
110  return encoding == RGB8 || encoding == BGR8 ||
111  encoding == RGBA8 || encoding == BGRA8 ||
112  encoding == RGB16 || encoding == BGR16 ||
113  encoding == RGBA16 || encoding == BGRA16;
114  }
115 
116  static inline bool isMono(const std::string& encoding)
117  {
118  return encoding == MONO8 || encoding == MONO16;
119  }
120 
121  static inline bool isBayer(const std::string& encoding)
122  {
123  return encoding == BAYER_RGGB8 || encoding == BAYER_BGGR8 ||
127  }
128 
129  static inline bool hasAlpha(const std::string& encoding)
130  {
131  return encoding == RGBA8 || encoding == BGRA8 ||
132  encoding == RGBA16 || encoding == BGRA16;
133  }
134 
135  static inline int numChannels(const std::string& encoding)
136  {
137  // First do the common-case encodings
138  if (encoding == MONO8 ||
139  encoding == MONO16)
140  return 1;
141  if (encoding == BGR8 ||
142  encoding == RGB8 ||
143  encoding == BGR16 ||
144  encoding == RGB16)
145  return 3;
146  if (encoding == BGRA8 ||
147  encoding == RGBA8 ||
148  encoding == BGRA16 ||
149  encoding == RGBA16)
150  return 4;
151  if (encoding == BAYER_RGGB8 ||
152  encoding == BAYER_BGGR8 ||
153  encoding == BAYER_GBRG8 ||
154  encoding == BAYER_GRBG8 ||
155  encoding == BAYER_RGGB16 ||
156  encoding == BAYER_BGGR16 ||
157  encoding == BAYER_GBRG16 ||
159  return 1;
160 
161  // Now all the generic content encodings
162  // TODO: Rewrite with regex when ROS supports C++11
163  for (size_t i=0; i < sizeof(ABSTRACT_ENCODING_PREFIXES) / sizeof(*ABSTRACT_ENCODING_PREFIXES); i++)
164  {
165  std::string prefix = ABSTRACT_ENCODING_PREFIXES[i];
166  if (encoding.substr(0, prefix.size()) != prefix)
167  continue;
168  if (encoding.size() == prefix.size())
169  return 1; // ex. 8UC -> 1
170  int n_channel = atoi(encoding.substr(prefix.size(),
171  encoding.size() - prefix.size()).c_str()); // ex. 8UC5 -> 5
172  if (n_channel != 0)
173  return n_channel; // valid encoding string
174  }
175 
176  if (encoding == YUV422)
177  return 2;
178 
179  throw std::runtime_error("Unknown encoding " + encoding);
180  return -1;
181  }
182 
183  static inline int bitDepth(const std::string& encoding)
184  {
185  if (encoding == MONO16)
186  return 16;
187  if (encoding == MONO8 ||
188  encoding == BGR8 ||
189  encoding == RGB8 ||
190  encoding == BGRA8 ||
191  encoding == RGBA8 ||
192  encoding == BAYER_RGGB8 ||
193  encoding == BAYER_BGGR8 ||
194  encoding == BAYER_GBRG8 ||
196  return 8;
197 
198  if (encoding == MONO16 ||
199  encoding == BGR16 ||
200  encoding == RGB16 ||
201  encoding == BGRA16 ||
202  encoding == RGBA16 ||
203  encoding == BAYER_RGGB16 ||
204  encoding == BAYER_BGGR16 ||
205  encoding == BAYER_GBRG16 ||
207  return 16;
208 
209  // Now all the generic content encodings
210  // TODO: Rewrite with regex when ROS supports C++11
211  for (size_t i=0; i < sizeof(ABSTRACT_ENCODING_PREFIXES) / sizeof(*ABSTRACT_ENCODING_PREFIXES); i++)
212  {
213  std::string prefix = ABSTRACT_ENCODING_PREFIXES[i];
214  if (encoding.substr(0, prefix.size()) != prefix)
215  continue;
216  if (encoding.size() == prefix.size())
217  return atoi(prefix.c_str()); // ex. 8UC -> 8
218  int n_channel = atoi(encoding.substr(prefix.size(),
219  encoding.size() - prefix.size()).c_str()); // ex. 8UC10 -> 10
220  if (n_channel != 0)
221  return atoi(prefix.c_str()); // valid encoding string
222  }
223 
224  if (encoding == YUV422)
225  return 8;
226 
227  throw std::runtime_error("Unknown encoding " + encoding);
228  return -1;
229  }
230  }
231 }
232 
233 #endif
sensor_msgs::image_encodings::BAYER_RGGB8
const std::string BAYER_RGGB8
sensor_msgs::image_encodings::TYPE_8UC3
const std::string TYPE_8UC3
sensor_msgs::image_encodings::TYPE_8UC1
const std::string TYPE_8UC1
sensor_msgs::image_encodings::TYPE_16SC4
const std::string TYPE_16SC4
sensor_msgs::image_encodings::TYPE_16UC4
const std::string TYPE_16UC4
sensor_msgs::image_encodings::RGBA8
const std::string RGBA8
sensor_msgs::image_encodings::BAYER_GBRG8
const std::string BAYER_GBRG8
sensor_msgs::image_encodings::isColor
static bool isColor(const std::string &encoding)
sensor_msgs::image_encodings::TYPE_8UC4
const std::string TYPE_8UC4
sensor_msgs::image_encodings::TYPE_8SC4
const std::string TYPE_8SC4
sensor_msgs::image_encodings::TYPE_64FC3
const std::string TYPE_64FC3
sensor_msgs::image_encodings::RGB8
const std::string RGB8
sensor_msgs::image_encodings::isBayer
static bool isBayer(const std::string &encoding)
sensor_msgs::image_encodings::ABSTRACT_ENCODING_PREFIXES
const std::string ABSTRACT_ENCODING_PREFIXES[]
sensor_msgs::image_encodings::TYPE_16UC1
const std::string TYPE_16UC1
sensor_msgs::image_encodings::TYPE_32FC4
const std::string TYPE_32FC4
encoding
dictionary encoding
sensor_msgs::image_encodings::TYPE_16SC3
const std::string TYPE_16SC3
sensor_msgs::image_encodings::TYPE_8SC1
const std::string TYPE_8SC1
sensor_msgs::image_encodings::BGR16
const std::string BGR16
sensor_msgs::image_encodings::hasAlpha
static bool hasAlpha(const std::string &encoding)
sensor_msgs::image_encodings::BAYER_BGGR8
const std::string BAYER_BGGR8
sensor_msgs::image_encodings::TYPE_32SC2
const std::string TYPE_32SC2
sensor_msgs::image_encodings::numChannels
static int numChannels(const std::string &encoding)
sensor_msgs::image_encodings::isMono
static bool isMono(const std::string &encoding)
sensor_msgs::image_encodings::TYPE_8SC3
const std::string TYPE_8SC3
sensor_msgs::image_encodings::YUV422
const std::string YUV422
sensor_msgs::image_encodings::BAYER_BGGR16
const std::string BAYER_BGGR16
sensor_msgs::image_encodings::TYPE_32SC3
const std::string TYPE_32SC3
sensor_msgs::image_encodings::BGRA16
const std::string BGRA16
sensor_msgs::image_encodings::BAYER_GBRG16
const std::string BAYER_GBRG16
sensor_msgs::image_encodings::TYPE_32SC4
const std::string TYPE_32SC4
sensor_msgs::image_encodings::bitDepth
static int bitDepth(const std::string &encoding)
sensor_msgs::image_encodings::TYPE_16SC2
const std::string TYPE_16SC2
sensor_msgs::image_encodings::TYPE_32FC2
const std::string TYPE_32FC2
sensor_msgs::image_encodings::TYPE_32FC3
const std::string TYPE_32FC3
sensor_msgs::image_encodings::RGBA16
const std::string RGBA16
sensor_msgs::image_encodings::BGRA8
const std::string BGRA8
sensor_msgs::image_encodings::TYPE_32SC1
const std::string TYPE_32SC1
sensor_msgs::image_encodings::TYPE_32FC1
const std::string TYPE_32FC1
sensor_msgs::image_encodings::MONO8
const std::string MONO8
sensor_msgs::image_encodings::TYPE_8SC2
const std::string TYPE_8SC2
sensor_msgs::image_encodings::TYPE_8UC2
const std::string TYPE_8UC2
sensor_msgs::image_encodings::MONO16
const std::string MONO16
sick_scan_base.h
sensor_msgs::image_encodings::TYPE_16UC2
const std::string TYPE_16UC2
sensor_msgs::image_encodings::TYPE_16SC1
const std::string TYPE_16SC1
sensor_msgs::image_encodings::TYPE_64FC4
const std::string TYPE_64FC4
sensor_msgs::image_encodings::BGR8
const std::string BGR8
sensor_msgs::image_encodings::TYPE_16UC3
const std::string TYPE_16UC3
sensor_msgs::image_encodings::BAYER_GRBG8
const std::string BAYER_GRBG8
sensor_msgs::image_encodings::TYPE_64FC1
const std::string TYPE_64FC1
sensor_msgs
Tools for manipulating sensor_msgs.
sensor_msgs::image_encodings::BAYER_GRBG16
const std::string BAYER_GRBG16
sensor_msgs::image_encodings::TYPE_64FC2
const std::string TYPE_64FC2
sensor_msgs::image_encodings::RGB16
const std::string RGB16
sensor_msgs::image_encodings::BAYER_RGGB16
const std::string BAYER_RGGB16


sick_scan_xd
Author(s): Michael Lehning , Jochen Sprickerhof , Martin Günther
autogenerated on Fri Oct 25 2024 02:47:08