Gazebo Msgs

API Reference

10.3.1
PixelFormatType.hh
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2023 Open Source Robotics Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17 #ifndef GZ_MSGS_CONVERT_PIXELFORMATTYPE_HH_
18 #define GZ_MSGS_CONVERT_PIXELFORMATTYPE_HH_
19 
20 // Message Headers
21 #include "gz/msgs/image.pb.h"
22 
23 // Data Headers
24 #include <string>
25 
26 namespace gz::msgs {
27 // Inline bracket to help doxygen filtering.
28 inline namespace GZ_MSGS_VERSION_NAMESPACE {
29 
31 inline msgs::PixelFormatType ConvertPixelFormatType(const std::string &_str)
32 {
33  if (_str == "L_INT8")
34  {
35  return msgs::PixelFormatType::L_INT8;
36  }
37  else if (_str == "L_INT16")
38  {
39  return msgs::PixelFormatType::L_INT16;
40  }
41  else if (_str == "RGB_INT8")
42  {
43  return msgs::PixelFormatType::RGB_INT8;
44  }
45  else if (_str == "RGBA_INT8")
46  {
47  return msgs::PixelFormatType::RGBA_INT8;
48  }
49  else if (_str == "BGRA_INT8")
50  {
51  return msgs::PixelFormatType::BGRA_INT8;
52  }
53  else if (_str == "RGB_INT16")
54  {
55  return msgs::PixelFormatType::RGB_INT16;
56  }
57  else if (_str == "RGB_INT32")
58  {
59  return msgs::PixelFormatType::RGB_INT32;
60  }
61  else if (_str == "BGR_INT8")
62  {
63  return msgs::PixelFormatType::BGR_INT8;
64  }
65  else if (_str == "BGR_INT16")
66  {
67  return msgs::PixelFormatType::BGR_INT16;
68  }
69  else if (_str == "BGR_INT32")
70  {
71  return msgs::PixelFormatType::BGR_INT32;
72  }
73  else if (_str == "R_FLOAT16")
74  {
75  return msgs::PixelFormatType::R_FLOAT16;
76  }
77  else if (_str == "RGB_FLOAT16")
78  {
79  return msgs::PixelFormatType::RGB_FLOAT16;
80  }
81  else if (_str == "R_FLOAT32")
82  {
83  return msgs::PixelFormatType::R_FLOAT32;
84  }
85  else if (_str == "RGB_FLOAT32")
86  {
87  return msgs::PixelFormatType::RGB_FLOAT32;
88  }
89  else if (_str == "BAYER_RGGB8")
90  {
91  return msgs::PixelFormatType::BAYER_RGGB8;
92  }
93  else if (_str == "BAYER_BGGR8")
94  {
95  return msgs::PixelFormatType::BAYER_BGGR8;
96  }
97  else if (_str == "BAYER_GBRG8")
98  {
99  return msgs::PixelFormatType::BAYER_GBRG8;
100  }
101  else if (_str == "BAYER_GRBG8")
102  {
103  return msgs::PixelFormatType::BAYER_GRBG8;
104  }
105 
106  return msgs::PixelFormatType::UNKNOWN_PIXEL_FORMAT;
107 }
108 
110 inline std::string ConvertPixelFormatType(const msgs::PixelFormatType &_t)
111 {
112  switch (_t)
113  {
114  default:
115  case msgs::PixelFormatType::UNKNOWN_PIXEL_FORMAT:
116  return "UNKNOWN_PIXEL_FORMAT";
117  case msgs::PixelFormatType::L_INT8:
118  return "L_INT8";
119  case msgs::PixelFormatType::L_INT16:
120  return "L_INT16";
121  case msgs::PixelFormatType::RGB_INT8:
122  return "RGB_INT8";
123  case msgs::PixelFormatType::RGBA_INT8:
124  return "RGBA_INT8";
125  case msgs::PixelFormatType::BGRA_INT8:
126  return "BGRA_INT8";
127  case msgs::PixelFormatType::RGB_INT16:
128  return "RGB_INT16";
129  case msgs::PixelFormatType::RGB_INT32:
130  return "RGB_INT32";
131  case msgs::PixelFormatType::BGR_INT8:
132  return "BGR_INT8";
133  case msgs::PixelFormatType::BGR_INT16:
134  return "BGR_INT16";
135  case msgs::PixelFormatType::BGR_INT32:
136  return "BGR_INT32";
137  case msgs::PixelFormatType::R_FLOAT16:
138  return "R_FLOAT16";
139  case msgs::PixelFormatType::RGB_FLOAT16:
140  return "RGB_FLOAT16";
141  case msgs::PixelFormatType::R_FLOAT32:
142  return "R_FLOAT32";
143  case msgs::PixelFormatType::RGB_FLOAT32:
144  return "RGB_FLOAT32";
145  case msgs::PixelFormatType::BAYER_RGGB8:
146  return "BAYER_RGGB8";
147  case msgs::PixelFormatType::BAYER_BGGR8:
148  return "BAYER_BGGR8";
149  case msgs::PixelFormatType::BAYER_GBRG8:
150  return "BAYER_GBRG8";
151  case msgs::PixelFormatType::BAYER_GRBG8:
152  return "BAYER_GRBG8";
153  };
154 }
155 
156 
157 } // namespce
158 } // namespace gz::msgs
159 
160 #endif // GZ_MSGS_CONVERT_PIXELFORMATTYPE_HH_