YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
ImageNetworkHeader.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-FileCopyrightText: 2006-2010 RobotCub Consortium
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef YARP_SIG_IMAGENETWORKHEADER_H
8#define YARP_SIG_IMAGENETWORKHEADER_H
9
10#include <yarp/conf/system.h>
11
12#include <yarp/os/NetInt32.h>
13#include <yarp/os/NetInt16.h>
14#include <yarp/os/Bottle.h>
15
16#include <yarp/sig/Image.h>
17
18namespace yarp::sig {
19
25{
26public:
34 // WARNING This is 5 and not 6 because quantum and topIsLow are
35 // transmitted in the same 32 bits for compatibility with
36 // YARP 3.4 and older
41 // WARNING The topIsLowIndex field in the ImageNetworkHeader is `0` for
42 // `true` and `1` for `false` for compatibility with YARP 3.4
43 // and older
49
50 void setFromImage(const Image& image)
51 {
52 id = image.getPixelCode();
53 depth = image.getPixelSize();
54 imgSize = image.getRawImageSize();
55 quantum = static_cast<yarp::os::NetInt16>(image.getQuantum());
56 topIsLow = 1;
57 width = image.width();
58 height = image.height();
60 }
61
62 void setToImage(FlexImage& image)
63 {
64 image.setPixelCode(id);
65 //setPixelSize() is already set by setPixelCode
66 image.setQuantum(quantum);
67 image.resize(width, height);
68 }
69};
71
72} // namespace yarp::sig
73
74#endif // YARP_SIG_IMAGENETWORKHEADER_H
#define BOTTLE_TAG_INT32
Definition Bottle.h:21
#define BOTTLE_TAG_BLOB
Definition Bottle.h:27
#define BOTTLE_TAG_LIST
Definition Bottle.h:28
#define BOTTLE_TAG_VOCAB32
Definition Bottle.h:23
Image class with user control of representation details.
Definition Image.h:363
void setQuantum(size_t imgQuantum)
Definition Image.h:378
void setPixelCode(int imgPixelCode)
Definition Image.h:366
Byte order in image header for network transmission.
const yarp::os::NetInt32 paramIdTag
const yarp::os::NetInt32 paramListTag
const yarp::os::NetInt32 paramNameTag
void setToImage(FlexImage &image)
const yarp::os::NetInt32 listTag
const yarp::os::NetInt32 paramBlobTag
const yarp::os::NetInt32 paramListLen
void setFromImage(const Image &image)
const yarp::os::NetInt32 paramName
const yarp::os::NetInt32 listLen
Base class for storing images.
Definition Image.h:79
size_t width() const
Gets width of image in pixels.
Definition Image.h:171
virtual size_t getPixelSize() const
Gets pixel size in memory in bytes.
Definition Image.cpp:385
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:488
void resize(size_t imgWidth, size_t imgHeight)
Reallocate an image to be of a desired size, throwing away its current contents.
Definition Image.cpp:402
size_t getQuantum() const
The size of a row is constrained to be a multiple of the "quantum".
Definition Image.h:204
size_t height() const
Gets height of image in pixels.
Definition Image.h:177
virtual int getPixelCode() const
Gets pixel type identifier.
Definition Image.cpp:390
std::int16_t NetInt16
Definition of the NetInt16 type.
Definition NetInt16.h:29
std::int32_t NetInt32
Definition of the NetInt32 type.
Definition NetInt32.h:29
constexpr yarp::conf::vocab32_t createVocab32(char a, char b=0, char c=0, char d=0)
Create a vocab from chars.
Definition Vocab.h:27
#define YARP_END_PACK
Ends 1 byte packing for structs/classes.
Definition system.h:193
#define YARP_BEGIN_PACK
Starts 1 byte packing for structs/classes.
Definition system.h:192