YARP
Yet Another Robot Platform
RegionOfInterest.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 "sensor_msgs/RegionOfInterest" msg definition:
9 // # This message is used to specify a region of interest within an image.
10 // #
11 // # When used to specify the ROI setting of the camera when the image was
12 // # taken, the height and width fields should either match the height and
13 // # width fields for the associated image; or height = width = 0
14 // # indicates that the full resolution image was captured.
15 //
16 // uint32 x_offset # Leftmost pixel of the ROI
17 // # (0 if the ROI includes the left edge of the image)
18 // uint32 y_offset # Topmost pixel of the ROI
19 // # (0 if the ROI includes the top edge of the image)
20 // uint32 height # Height of ROI
21 // uint32 width # Width of ROI
22 //
23 // # True if a distinct rectified ROI should be calculated from the "raw"
24 // # ROI in this message. Typically this should be False if the full image
25 // # is captured (ROI not used), and True if a subwindow is captured (ROI
26 // # used).
27 // bool do_rectify
28 // Instances of this class can be read and written with YARP ports,
29 // using a ROS-compatible format.
30 
31 #ifndef YARP_ROSMSG_sensor_msgs_RegionOfInterest_h
32 #define YARP_ROSMSG_sensor_msgs_RegionOfInterest_h
33 
34 #include <yarp/os/Wire.h>
35 #include <yarp/os/Type.h>
36 #include <yarp/os/idl/WireTypes.h>
37 #include <string>
38 #include <vector>
39 
40 namespace yarp {
41 namespace rosmsg {
42 namespace sensor_msgs {
43 
45 {
46 public:
47  std::uint32_t x_offset;
48  std::uint32_t y_offset;
49  std::uint32_t height;
50  std::uint32_t width;
51  bool do_rectify;
52 
54  x_offset(0),
55  y_offset(0),
56  height(0),
57  width(0),
58  do_rectify(false)
59  {
60  }
61 
62  void clear()
63  {
64  // *** x_offset ***
65  x_offset = 0;
66 
67  // *** y_offset ***
68  y_offset = 0;
69 
70  // *** height ***
71  height = 0;
72 
73  // *** width ***
74  width = 0;
75 
76  // *** do_rectify ***
77  do_rectify = false;
78  }
79 
80  bool readBare(yarp::os::ConnectionReader& connection) override
81  {
82  // *** x_offset ***
83  x_offset = connection.expectInt32();
84 
85  // *** y_offset ***
86  y_offset = connection.expectInt32();
87 
88  // *** height ***
89  height = connection.expectInt32();
90 
91  // *** width ***
92  width = connection.expectInt32();
93 
94  // *** do_rectify ***
95  if (!connection.expectBlock((char*)&do_rectify, 1)) {
96  return false;
97  }
98 
99  return !connection.isError();
100  }
101 
102  bool readBottle(yarp::os::ConnectionReader& connection) override
103  {
104  connection.convertTextMode();
105  yarp::os::idl::WireReader reader(connection);
106  if (!reader.readListHeader(5)) {
107  return false;
108  }
109 
110  // *** x_offset ***
111  x_offset = reader.expectInt32();
112 
113  // *** y_offset ***
114  y_offset = reader.expectInt32();
115 
116  // *** height ***
117  height = reader.expectInt32();
118 
119  // *** width ***
120  width = reader.expectInt32();
121 
122  // *** do_rectify ***
123  do_rectify = reader.expectInt8();
124 
125  return !connection.isError();
126  }
127 
129  bool read(yarp::os::ConnectionReader& connection) override
130  {
131  return (connection.isBareMode() ? readBare(connection)
132  : readBottle(connection));
133  }
134 
135  bool writeBare(yarp::os::ConnectionWriter& connection) const override
136  {
137  // *** x_offset ***
138  connection.appendInt32(x_offset);
139 
140  // *** y_offset ***
141  connection.appendInt32(y_offset);
142 
143  // *** height ***
144  connection.appendInt32(height);
145 
146  // *** width ***
147  connection.appendInt32(width);
148 
149  // *** do_rectify ***
150  connection.appendBlock((char*)&do_rectify, 1);
151 
152  return !connection.isError();
153  }
154 
155  bool writeBottle(yarp::os::ConnectionWriter& connection) const override
156  {
157  connection.appendInt32(BOTTLE_TAG_LIST);
158  connection.appendInt32(5);
159 
160  // *** x_offset ***
161  connection.appendInt32(BOTTLE_TAG_INT32);
162  connection.appendInt32(x_offset);
163 
164  // *** y_offset ***
165  connection.appendInt32(BOTTLE_TAG_INT32);
166  connection.appendInt32(y_offset);
167 
168  // *** height ***
169  connection.appendInt32(BOTTLE_TAG_INT32);
170  connection.appendInt32(height);
171 
172  // *** width ***
173  connection.appendInt32(BOTTLE_TAG_INT32);
174  connection.appendInt32(width);
175 
176  // *** do_rectify ***
177  connection.appendInt32(BOTTLE_TAG_INT8);
178  connection.appendInt8(do_rectify);
179 
180  connection.convertTextMode();
181  return !connection.isError();
182  }
183 
185  bool write(yarp::os::ConnectionWriter& connection) const override
186  {
187  return (connection.isBareMode() ? writeBare(connection)
188  : writeBottle(connection));
189  }
190 
191  // This class will serialize ROS style or YARP style depending on protocol.
192  // If you need to force a serialization style, use one of these classes:
195 
196  // The name for this message, ROS will need this
197  static constexpr const char* typeName = "sensor_msgs/RegionOfInterest";
198 
199  // The checksum for this message, ROS will need this
200  static constexpr const char* typeChecksum = "bdb633039d588fcccb441a4d43ccfe09";
201 
202  // The source text for this message, ROS will need this
203  static constexpr const char* typeText = "\
204 # This message is used to specify a region of interest within an image.\n\
205 #\n\
206 # When used to specify the ROI setting of the camera when the image was\n\
207 # taken, the height and width fields should either match the height and\n\
208 # width fields for the associated image; or height = width = 0\n\
209 # indicates that the full resolution image was captured.\n\
210 \n\
211 uint32 x_offset # Leftmost pixel of the ROI\n\
212  # (0 if the ROI includes the left edge of the image)\n\
213 uint32 y_offset # Topmost pixel of the ROI\n\
214  # (0 if the ROI includes the top edge of the image)\n\
215 uint32 height # Height of ROI\n\
216 uint32 width # Width of ROI\n\
217 \n\
218 # True if a distinct rectified ROI should be calculated from the \"raw\"\n\
219 # ROI in this message. Typically this should be False if the full image\n\
220 # is captured (ROI not used), and True if a subwindow is captured (ROI\n\
221 # used).\n\
222 bool do_rectify\n\
223 ";
224 
225  yarp::os::Type getType() const override
226  {
228  typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
229  typ.addProperty("message_definition", yarp::os::Value(typeText));
230  return typ;
231  }
232 };
233 
234 } // namespace sensor_msgs
235 } // namespace rosmsg
236 } // namespace yarp
237 
238 #endif // YARP_ROSMSG_sensor_msgs_RegionOfInterest_h
#define BOTTLE_TAG_INT8
Definition: Bottle.h:19
#define BOTTLE_TAG_INT32
Definition: Bottle.h:21
#define BOTTLE_TAG_LIST
Definition: Bottle.h:28
An interface for reading from a network connection.
virtual bool expectBlock(char *data, size_t len)=0
Read a block of data from the network connection.
virtual bool isBareMode() const =0
Check if the connection is bare mode.
virtual std::int32_t expectInt32()=0
Read a 32-bit integer from the network connection.
virtual bool convertTextMode()=0
Reads in a standard description in text mode, and converts it to a standard description in binary.
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 appendInt8(std::int8_t data)=0
Send a representation of a 8-bit integer 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.
virtual void appendBlock(const char *data, size_t len)=0
Send a block of data 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:45
A "tamed" Portable, that promises to serialize itself in an IDL-friendly way.
Definition: WirePortable.h:23
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:30
std::int8_t expectInt8()
Definition: WireReader.h:80
std::int32_t expectInt32()
Definition: WireReader.h:92
static constexpr const char * typeName
yarp::os::idl::BottleStyle< yarp::rosmsg::sensor_msgs::RegionOfInterest > bottleStyle
bool readBare(yarp::os::ConnectionReader &connection) override
yarp::os::idl::BareStyle< yarp::rosmsg::sensor_msgs::RegionOfInterest > rosStyle
static constexpr const char * typeText
bool writeBare(yarp::os::ConnectionWriter &connection) const override
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
bool readBottle(yarp::os::ConnectionReader &connection) override
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
static constexpr const char * typeChecksum
yarp::os::Type getType() const override
The main, catch-all namespace for YARP.
Definition: dirs.h:16