YARP
Yet Another Robot Platform
ImageNetworkHeader.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * Copyright (C) 2006-2010 RobotCub Consortium
4  * All rights reserved.
5  *
6  * This software may be modified and distributed under the terms of the
7  * BSD-3-Clause license. See the accompanying LICENSE file for details.
8  */
9 
10 #ifndef YARP_SIG_IMAGENETWORKHEADER_H
11 #define YARP_SIG_IMAGENETWORKHEADER_H
12 
13 #include <yarp/conf/system.h>
14 
15 #include <yarp/os/NetInt16.h>
16 #include <yarp/os/NetInt32.h>
17 #include <yarp/os/Bottle.h>
18 
19 #include <yarp/sig/Image.h>
20 
21 namespace yarp {
22  namespace sig {
23  class ImageNetworkHeader;
24  }
25 }
26 
34 {
35 public:
36 
53 
55  paramName(0), paramIdTag(0), id(0),
56  paramListTag(0), paramListLen(0), depth(0),
57  imgSize(0), quantum(0), topIsLow(0), width(0),
58  height(0), paramBlobTag(0), paramBlobLen(0) {}
59 
60  void setFromImage(const Image& image) {
62  listLen = 4;
64  paramName = yarp::os::createVocab('m','a','t');
66  id = image.getPixelCode();
68  // WARNING This is 5 and not 6 because quantum and topIsLow are
69  // transmitted in the same 32 bits for compatibility with
70  // YARP 3.4 and older
71  paramListLen = 5;
72  depth = image.getPixelSize();
73  imgSize = image.getRawImageSize();
74  quantum = static_cast<yarp::os::NetInt16>(image.getQuantum());
75  // WARNING The topIsLowIndex is always 0 for compatibility between
76  // YARP 3.4 and YARP 3.5
77  topIsLow = 0;
78  width = image.width();
79  height = image.height();
81  paramBlobLen = image.getRawImageSize();
82  }
83 
84 };
86 
87 #endif // YARP_SIG_IMAGENETWORKHEADER_H
#define BOTTLE_TAG_VOCAB
Definition: Bottle.h:25
#define BOTTLE_TAG_INT32
Definition: Bottle.h:23
#define BOTTLE_TAG_BLOB
Definition: Bottle.h:29
#define BOTTLE_TAG_LIST
Definition: Bottle.h:30
Byte order in image header for network transmission.
void setFromImage(const Image &image)
Base class for storing images.
Definition: Image.h:85
size_t width() const
Gets width of image in pixels.
Definition: Image.h:153
virtual size_t getPixelSize() const
Gets pixel size in memory in bytes.
Definition: Image.cpp:450
size_t getRawImageSize() const
Access to the internal buffer size information (this is how much memory has been allocated for the im...
Definition: Image.cpp:544
size_t getQuantum() const
The size of a row is constrained to be a multiple of the "quantum".
Definition: Image.h:186
size_t height() const
Gets height of image in pixels.
Definition: Image.h:159
virtual int getPixelCode() const
Gets pixel type identifier.
Definition: Image.cpp:455
std::int16_t NetInt16
Definition of the NetInt16 type.
Definition: NetInt16.h:33
std::int32_t NetInt32
Definition of the NetInt32 type.
Definition: NetInt32.h:33
constexpr yarp::conf::vocab32_t createVocab(char a, char b=0, char c=0, char d=0)
Definition: Vocab.h:22
The main, catch-all namespace for YARP.
Definition: environment.h:18
#define YARP_END_PACK
Ends 1 byte packing for structs/classes.
Definition: system.h:194
#define YARP_BEGIN_PACK
Starts 1 byte packing for structs/classes.
Definition: system.h:193