YARP
Yet Another Robot Platform
DisparityImage.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: BSD-3-Clause
4 */
5
6// This is an automatically generated file.
7
8// Generated from the following "stereo_msgs/DisparityImage" msg definition:
9// # Separate header for compatibility with current TimeSynchronizer.
10// # Likely to be removed in a later release, use image.header instead.
11// Header header
12//
13// # Floating point disparity image. The disparities are pre-adjusted for any
14// # x-offset between the principal points of the two cameras (in the case
15// # that they are verged). That is: d = x_l - x_r - (cx_l - cx_r)
16// sensor_msgs/Image image
17//
18// # Stereo geometry. For disparity d, the depth from the camera is Z = fT/d.
19// float32 f # Focal length, pixels
20// float32 T # Baseline, world units
21//
22// # Subwindow of (potentially) valid disparity values.
23// sensor_msgs/RegionOfInterest valid_window
24//
25// # The range of disparities searched.
26// # In the disparity image, any disparity less than min_disparity is invalid.
27// # The disparity search range defines the horopter, or 3D volume that the
28// # stereo algorithm can "see". Points with Z outside of:
29// # Z_min = fT / max_disparity
30// # Z_max = fT / min_disparity
31// # could not be found.
32// float32 min_disparity
33// float32 max_disparity
34//
35// # Smallest allowed disparity increment. The smallest achievable depth range
36// # resolution is delta_Z = (Z^2/fT)*delta_d.
37// float32 delta_d
38// Instances of this class can be read and written with YARP ports,
39// using a ROS-compatible format.
40
41#ifndef YARP_ROSMSG_stereo_msgs_DisparityImage_h
42#define YARP_ROSMSG_stereo_msgs_DisparityImage_h
43
44#include <yarp/os/Wire.h>
45#include <yarp/os/Type.h>
47#include <string>
48#include <vector>
52
53namespace yarp {
54namespace rosmsg {
55namespace stereo_msgs {
56
58{
59public:
65 yarp::conf::float32_t min_disparity;
66 yarp::conf::float32_t max_disparity;
68
70 header(),
71 image(),
72 f(0.0f),
73 T(0.0f),
74 valid_window(),
75 min_disparity(0.0f),
76 max_disparity(0.0f),
77 delta_d(0.0f)
78 {
79 }
80
81 void clear()
82 {
83 // *** header ***
84 header.clear();
85
86 // *** image ***
87 image.clear();
88
89 // *** f ***
90 f = 0.0f;
91
92 // *** T ***
93 T = 0.0f;
94
95 // *** valid_window ***
96 valid_window.clear();
97
98 // *** min_disparity ***
99 min_disparity = 0.0f;
100
101 // *** max_disparity ***
102 max_disparity = 0.0f;
103
104 // *** delta_d ***
105 delta_d = 0.0f;
106 }
107
108 bool readBare(yarp::os::ConnectionReader& connection) override
109 {
110 // *** header ***
111 if (!header.read(connection)) {
112 return false;
113 }
114
115 // *** image ***
116 if (!image.read(connection)) {
117 return false;
118 }
119
120 // *** f ***
121 f = connection.expectFloat32();
122
123 // *** T ***
124 T = connection.expectFloat32();
125
126 // *** valid_window ***
127 if (!valid_window.read(connection)) {
128 return false;
129 }
130
131 // *** min_disparity ***
132 min_disparity = connection.expectFloat32();
133
134 // *** max_disparity ***
135 max_disparity = connection.expectFloat32();
136
137 // *** delta_d ***
138 delta_d = connection.expectFloat32();
139
140 return !connection.isError();
141 }
142
143 bool readBottle(yarp::os::ConnectionReader& connection) override
144 {
145 connection.convertTextMode();
146 yarp::os::idl::WireReader reader(connection);
147 if (!reader.readListHeader(8)) {
148 return false;
149 }
150
151 // *** header ***
152 if (!header.read(connection)) {
153 return false;
154 }
155
156 // *** image ***
157 if (!image.read(connection)) {
158 return false;
159 }
160
161 // *** f ***
162 f = reader.expectFloat32();
163
164 // *** T ***
165 T = reader.expectFloat32();
166
167 // *** valid_window ***
168 if (!valid_window.read(connection)) {
169 return false;
170 }
171
172 // *** min_disparity ***
173 min_disparity = reader.expectFloat32();
174
175 // *** max_disparity ***
176 max_disparity = reader.expectFloat32();
177
178 // *** delta_d ***
179 delta_d = reader.expectFloat32();
180
181 return !connection.isError();
182 }
183
185 bool read(yarp::os::ConnectionReader& connection) override
186 {
187 return (connection.isBareMode() ? readBare(connection)
188 : readBottle(connection));
189 }
190
191 bool writeBare(yarp::os::ConnectionWriter& connection) const override
192 {
193 // *** header ***
194 if (!header.write(connection)) {
195 return false;
196 }
197
198 // *** image ***
199 if (!image.write(connection)) {
200 return false;
201 }
202
203 // *** f ***
204 connection.appendFloat32(f);
205
206 // *** T ***
207 connection.appendFloat32(T);
208
209 // *** valid_window ***
210 if (!valid_window.write(connection)) {
211 return false;
212 }
213
214 // *** min_disparity ***
215 connection.appendFloat32(min_disparity);
216
217 // *** max_disparity ***
218 connection.appendFloat32(max_disparity);
219
220 // *** delta_d ***
221 connection.appendFloat32(delta_d);
222
223 return !connection.isError();
224 }
225
226 bool writeBottle(yarp::os::ConnectionWriter& connection) const override
227 {
228 connection.appendInt32(BOTTLE_TAG_LIST);
229 connection.appendInt32(8);
230
231 // *** header ***
232 if (!header.write(connection)) {
233 return false;
234 }
235
236 // *** image ***
237 if (!image.write(connection)) {
238 return false;
239 }
240
241 // *** f ***
243 connection.appendFloat32(f);
244
245 // *** T ***
247 connection.appendFloat32(T);
248
249 // *** valid_window ***
250 if (!valid_window.write(connection)) {
251 return false;
252 }
253
254 // *** min_disparity ***
256 connection.appendFloat32(min_disparity);
257
258 // *** max_disparity ***
260 connection.appendFloat32(max_disparity);
261
262 // *** delta_d ***
264 connection.appendFloat32(delta_d);
265
266 connection.convertTextMode();
267 return !connection.isError();
268 }
269
271 bool write(yarp::os::ConnectionWriter& connection) const override
272 {
273 return (connection.isBareMode() ? writeBare(connection)
274 : writeBottle(connection));
275 }
276
277 // This class will serialize ROS style or YARP style depending on protocol.
278 // If you need to force a serialization style, use one of these classes:
281
282 // The name for this message, ROS will need this
283 static constexpr const char* typeName = "stereo_msgs/DisparityImage";
284
285 // The checksum for this message, ROS will need this
286 static constexpr const char* typeChecksum = "04a177815f75271039fa21f16acad8c9";
287
288 // The source text for this message, ROS will need this
289 static constexpr const char* typeText = "\
290# Separate header for compatibility with current TimeSynchronizer.\n\
291# Likely to be removed in a later release, use image.header instead.\n\
292Header header\n\
293\n\
294# Floating point disparity image. The disparities are pre-adjusted for any\n\
295# x-offset between the principal points of the two cameras (in the case\n\
296# that they are verged). That is: d = x_l - x_r - (cx_l - cx_r)\n\
297sensor_msgs/Image image\n\
298\n\
299# Stereo geometry. For disparity d, the depth from the camera is Z = fT/d.\n\
300float32 f # Focal length, pixels\n\
301float32 T # Baseline, world units\n\
302\n\
303# Subwindow of (potentially) valid disparity values.\n\
304sensor_msgs/RegionOfInterest valid_window\n\
305\n\
306# The range of disparities searched.\n\
307# In the disparity image, any disparity less than min_disparity is invalid.\n\
308# The disparity search range defines the horopter, or 3D volume that the\n\
309# stereo algorithm can \"see\". Points with Z outside of:\n\
310# Z_min = fT / max_disparity\n\
311# Z_max = fT / min_disparity\n\
312# could not be found.\n\
313float32 min_disparity\n\
314float32 max_disparity\n\
315\n\
316# Smallest allowed disparity increment. The smallest achievable depth range\n\
317# resolution is delta_Z = (Z^2/fT)*delta_d.\n\
318float32 delta_d\n\
319\n\
320================================================================================\n\
321MSG: std_msgs/Header\n\
322# Standard metadata for higher-level stamped data types.\n\
323# This is generally used to communicate timestamped data \n\
324# in a particular coordinate frame.\n\
325# \n\
326# sequence ID: consecutively increasing ID \n\
327uint32 seq\n\
328#Two-integer timestamp that is expressed as:\n\
329# * stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs')\n\
330# * stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs')\n\
331# time-handling sugar is provided by the client library\n\
332time stamp\n\
333#Frame this data is associated with\n\
334# 0: no frame\n\
335# 1: global frame\n\
336string frame_id\n\
337\n\
338================================================================================\n\
339MSG: sensor_msgs/Image\n\
340# This message contains an uncompressed image\n\
341# (0, 0) is at top-left corner of image\n\
342#\n\
343\n\
344Header header # Header timestamp should be acquisition time of image\n\
345 # Header frame_id should be optical frame of camera\n\
346 # origin of frame should be optical center of cameara\n\
347 # +x should point to the right in the image\n\
348 # +y should point down in the image\n\
349 # +z should point into to plane of the image\n\
350 # If the frame_id here and the frame_id of the CameraInfo\n\
351 # message associated with the image conflict\n\
352 # the behavior is undefined\n\
353\n\
354uint32 height # image height, that is, number of rows\n\
355uint32 width # image width, that is, number of columns\n\
356\n\
357# The legal values for encoding are in file src/image_encodings.cpp\n\
358# If you want to standardize a new string format, join\n\
359# ros-users@lists.sourceforge.net and send an email proposing a new encoding.\n\
360\n\
361string encoding # Encoding of pixels -- channel meaning, ordering, size\n\
362 # taken from the list of strings in include/sensor_msgs/image_encodings.h\n\
363\n\
364uint8 is_bigendian # is this data bigendian?\n\
365uint32 step # Full row length in bytes\n\
366uint8[] data # actual matrix data, size is (step * rows)\n\
367\n\
368================================================================================\n\
369MSG: sensor_msgs/RegionOfInterest\n\
370# This message is used to specify a region of interest within an image.\n\
371#\n\
372# When used to specify the ROI setting of the camera when the image was\n\
373# taken, the height and width fields should either match the height and\n\
374# width fields for the associated image; or height = width = 0\n\
375# indicates that the full resolution image was captured.\n\
376\n\
377uint32 x_offset # Leftmost pixel of the ROI\n\
378 # (0 if the ROI includes the left edge of the image)\n\
379uint32 y_offset # Topmost pixel of the ROI\n\
380 # (0 if the ROI includes the top edge of the image)\n\
381uint32 height # Height of ROI\n\
382uint32 width # Width of ROI\n\
383\n\
384# True if a distinct rectified ROI should be calculated from the \"raw\"\n\
385# ROI in this message. Typically this should be False if the full image\n\
386# is captured (ROI not used), and True if a subwindow is captured (ROI\n\
387# used).\n\
388bool do_rectify\n\
389";
390
391 yarp::os::Type getType() const override
392 {
393 yarp::os::Type typ = yarp::os::Type::byName(typeName, typeName);
394 typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
395 typ.addProperty("message_definition", yarp::os::Value(typeText));
396 return typ;
397 }
398};
399
400} // namespace stereo_msgs
401} // namespace rosmsg
402} // namespace yarp
403
404#endif // YARP_ROSMSG_stereo_msgs_DisparityImage_h
#define BOTTLE_TAG_LIST
Definition: Bottle.h:28
#define BOTTLE_TAG_FLOAT32
Definition: Bottle.h:24
An interface for reading from a network connection.
virtual bool isBareMode() const =0
Check if the connection is bare mode.
virtual bool convertTextMode()=0
Reads in a standard description in text mode, and converts it to a standard description in binary.
virtual yarp::conf::float32_t expectFloat32()=0
Read a 32-bit floating point number from the network connection.
virtual bool isError() const =0
An interface for writing to a network connection.
virtual bool isError() const =0
virtual bool isBareMode() const =0
Check if the connection is bare mode.
virtual void appendFloat32(yarp::conf::float32_t data)=0
Send a representation of a 32-bit floating point number to the network connection.
virtual bool convertTextMode()=0
Converts a standard description in binary into a textual description, if the connection is in text-mo...
virtual void appendInt32(std::int32_t data)=0
Send a representation of a 32-bit integer to the network connection.
static Type byName(const char *name)
Definition: Type.cpp:171
Type & addProperty(const char *key, const Value &val)
Definition: Type.cpp:134
A single value (typically within a Bottle).
Definition: Value.h:43
A "tamed" Portable, that promises to serialize itself in an IDL-friendly way.
Definition: WirePortable.h:21
virtual bool read(yarp::os::idl::WireReader &reader)
virtual bool write(const yarp::os::idl::WireWriter &writer) const
IDL-friendly connection reader.
Definition: WireReader.h:27
yarp::conf::float32_t expectFloat32()
Definition: WireReader.h:103
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: Header.h:159
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: Header.h:112
yarp::rosmsg::sensor_msgs::RegionOfInterest RegionOfInterest
yarp::rosmsg::sensor_msgs::Image Image
Definition: Image.h:21
yarp::rosmsg::stereo_msgs::DisparityImage DisparityImage
float float32_t
Definition: numeric.h:76
bool read(ImageOf< PixelRgb > &dest, const std::string &src, image_fileformat format=FORMAT_ANY)
Definition: ImageFile.cpp:915
bool write(const ImageOf< PixelRgb > &src, const std::string &dest, image_fileformat format=FORMAT_PPM)
Definition: ImageFile.cpp:1091
The main, catch-all namespace for YARP.
Definition: dirs.h:16