Gazebo Msgs

API Reference

11.0.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#include <gz/msgs/config.hh>
21
22// Message Headers
23#include "gz/msgs/image.pb.h"
24
25// Data Headers
26#include <string>
27
28namespace gz::msgs {
29// Inline bracket to help doxygen filtering.
30inline namespace GZ_MSGS_VERSION_NAMESPACE {
31
33inline msgs::PixelFormatType ConvertPixelFormatType(const std::string &_str)
34{
35 if (_str == "L_INT8")
36 {
37 return msgs::PixelFormatType::L_INT8;
38 }
39 else if (_str == "L_INT16")
40 {
41 return msgs::PixelFormatType::L_INT16;
42 }
43 else if (_str == "RGB_INT8")
44 {
45 return msgs::PixelFormatType::RGB_INT8;
46 }
47 else if (_str == "RGBA_INT8")
48 {
49 return msgs::PixelFormatType::RGBA_INT8;
50 }
51 else if (_str == "BGRA_INT8")
52 {
53 return msgs::PixelFormatType::BGRA_INT8;
54 }
55 else if (_str == "RGB_INT16")
56 {
57 return msgs::PixelFormatType::RGB_INT16;
58 }
59 else if (_str == "RGB_INT32")
60 {
61 return msgs::PixelFormatType::RGB_INT32;
62 }
63 else if (_str == "BGR_INT8")
64 {
65 return msgs::PixelFormatType::BGR_INT8;
66 }
67 else if (_str == "BGR_INT16")
68 {
69 return msgs::PixelFormatType::BGR_INT16;
70 }
71 else if (_str == "BGR_INT32")
72 {
73 return msgs::PixelFormatType::BGR_INT32;
74 }
75 else if (_str == "R_FLOAT16")
76 {
77 return msgs::PixelFormatType::R_FLOAT16;
78 }
79 else if (_str == "RGB_FLOAT16")
80 {
81 return msgs::PixelFormatType::RGB_FLOAT16;
82 }
83 else if (_str == "R_FLOAT32")
84 {
85 return msgs::PixelFormatType::R_FLOAT32;
86 }
87 else if (_str == "RGB_FLOAT32")
88 {
89 return msgs::PixelFormatType::RGB_FLOAT32;
90 }
91 else if (_str == "BAYER_RGGB8")
92 {
93 return msgs::PixelFormatType::BAYER_RGGB8;
94 }
95 else if (_str == "BAYER_BGGR8")
96 {
97 return msgs::PixelFormatType::BAYER_BGGR8;
98 }
99 else if (_str == "BAYER_GBRG8")
100 {
101 return msgs::PixelFormatType::BAYER_GBRG8;
102 }
103 else if (_str == "BAYER_GRBG8")
104 {
105 return msgs::PixelFormatType::BAYER_GRBG8;
106 }
107
108 return msgs::PixelFormatType::UNKNOWN_PIXEL_FORMAT;
109}
110
112inline std::string ConvertPixelFormatType(const msgs::PixelFormatType &_t)
113{
114 switch (_t)
115 {
116 default:
117 case msgs::PixelFormatType::UNKNOWN_PIXEL_FORMAT:
118 return "UNKNOWN_PIXEL_FORMAT";
119 case msgs::PixelFormatType::L_INT8:
120 return "L_INT8";
121 case msgs::PixelFormatType::L_INT16:
122 return "L_INT16";
123 case msgs::PixelFormatType::RGB_INT8:
124 return "RGB_INT8";
125 case msgs::PixelFormatType::RGBA_INT8:
126 return "RGBA_INT8";
127 case msgs::PixelFormatType::BGRA_INT8:
128 return "BGRA_INT8";
129 case msgs::PixelFormatType::RGB_INT16:
130 return "RGB_INT16";
131 case msgs::PixelFormatType::RGB_INT32:
132 return "RGB_INT32";
133 case msgs::PixelFormatType::BGR_INT8:
134 return "BGR_INT8";
135 case msgs::PixelFormatType::BGR_INT16:
136 return "BGR_INT16";
137 case msgs::PixelFormatType::BGR_INT32:
138 return "BGR_INT32";
139 case msgs::PixelFormatType::R_FLOAT16:
140 return "R_FLOAT16";
141 case msgs::PixelFormatType::RGB_FLOAT16:
142 return "RGB_FLOAT16";
143 case msgs::PixelFormatType::R_FLOAT32:
144 return "R_FLOAT32";
145 case msgs::PixelFormatType::RGB_FLOAT32:
146 return "RGB_FLOAT32";
147 case msgs::PixelFormatType::BAYER_RGGB8:
148 return "BAYER_RGGB8";
149 case msgs::PixelFormatType::BAYER_BGGR8:
150 return "BAYER_BGGR8";
151 case msgs::PixelFormatType::BAYER_GBRG8:
152 return "BAYER_GBRG8";
153 case msgs::PixelFormatType::BAYER_GRBG8:
154 return "BAYER_GRBG8";
155 };
156}
157
158
159} // namespce
160} // namespace gz::msgs
161
162#endif // GZ_MSGS_CONVERT_PIXELFORMATTYPE_HH_