buffer.h
Go to the documentation of this file.
1 /*
2  * This file is part of the rc_genicam_api package.
3  *
4  * Copyright (c) 2017 Roboception GmbH
5  * All rights reserved
6  *
7  * Author: Heiko Hirschmueller
8  *
9  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions are met:
11  *
12  * 1. Redistributions of source code must retain the above copyright notice,
13  * this list of conditions and the following disclaimer.
14  *
15  * 2. Redistributions in binary form must reproduce the above copyright notice,
16  * this list of conditions and the following disclaimer in the documentation
17  * and/or other materials provided with the distribution.
18  *
19  * 3. Neither the name of the copyright holder nor the names of its contributors
20  * may be used to endorse or promote products derived from this software without
21  * specific prior written permission.
22  *
23  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
29  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
30  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
31  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
32  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  */
35 
36 #ifndef RC_GENICAM_API_BUFFER
37 #define RC_GENICAM_API_BUFFER
38 
39 #include <memory>
40 #include <string>
41 
42 namespace rcg
43 {
44 
45 class Stream;
46 class GenTLWrapper;
47 
54 {
55  PAYLOAD_TYPE_UNKNOWN = 0, /* GenTL v1.2 */
56  PAYLOAD_TYPE_IMAGE = 1, /* GenTL v1.2 */
57  PAYLOAD_TYPE_RAW_DATA = 2, /* GenTL v1.2 */
58  PAYLOAD_TYPE_FILE = 3, /* GenTL v1.2 */
59  PAYLOAD_TYPE_CHUNK_DATA = 4, /* GenTL v1.2, Deprecated in GenTL 1.5*/
60  PAYLOAD_TYPE_JPEG = 5, /* GenTL v1.4 */
61  PAYLOAD_TYPE_JPEG2000 = 6, /* GenTL v1.4 */
62  PAYLOAD_TYPE_H264 = 7, /* GenTL v1.4 */
63  PAYLOAD_TYPE_CHUNK_ONLY = 8, /* GenTL v1.4 */
64  PAYLOAD_TYPE_DEVICE_SPECIFIC = 9, /* GenTL v1.4 */
65  PAYLOAD_TYPE_MULTI_PART = 10, /* GenTL v1.5 */
66 
67  PAYLOAD_TYPE_CUSTOM_ID = 1000 /* Starting value for GenTL Producer custom IDs. */
68 };
69 
76 {
77  PIXELFORMAT_NAMESPACE_UNKNOWN = 0, /* GenTL v1.2 */
78  PIXELFORMAT_NAMESPACE_GEV = 1, /* GenTL v1.2 */
79  PIXELFORMAT_NAMESPACE_IIDC = 2, /* GenTL v1.2 */
80  PIXELFORMAT_NAMESPACE_PFNC_16BIT = 3, /* GenTL v1.4 */
81  PIXELFORMAT_NAMESPACE_PFNC_32BIT = 4, /* GenTL v1.4 */
82 
83  PIXELFORMAT_NAMESPACE_CUSTOM_ID = 1000 /* Starting value for GenTL Producer custom IDs. */
84 };
85 
92 {
93  PART_DATATYPE_UNKNOWN = 0, /* Unknown data type */
94  PART_DATATYPE_2D_IMAGE = 1, /* Color or monochrome 2D image. */
95  PART_DATATYPE_2D_PLANE_BIPLANAR = 2, /* Single color plane of a planar 2D image consisting of 2 planes. */
96  PART_DATATYPE_2D_PLANE_TRIPLANAR = 3, /* Single color plane of a planar 2D image consisting of 3 planes. */
97  PART_DATATYPE_2D_PLANE_QUADPLANAR = 4, /* Single color plane of a planar 2D image consisting of 4 planes. */
98  PART_DATATYPE_3D_IMAGE = 5, /* 3D image (pixel coordinates). */
99  PART_DATATYPE_3D_PLANE_BIPLANAR = 6, /* Single plane of a planar 3D image consisting of 2 planes. */
100  PART_DATATYPE_3D_PLANE_TRIPLANAR = 7, /* Single plane of a planar 3D image consisting of 3 planes. */
101  PART_DATATYPE_3D_PLANE_QUADPLANAR = 8, /* Single plane of a planar 3D image consisting of 4 planes. */
102  PART_DATATYPE_CONFIDENCE_MAP = 9, /* Confidence of the individual pixel values. */
103  PART_DATATYPE_CHUNKDATA = 10, /* Chunk data type */
104 
105  PART_DATATYPE_CUSTOM_ID = 1000 /* Starting value for GenTL Producer custom IDs. */
106 };
107 
115 class Buffer
116 {
117  public:
118 
124  Buffer(const std::shared_ptr<const GenTLWrapper> &gentl, Stream *parent);
125 
133  void setHandle(void *handle);
134 
142  std::uint32_t getNumberOfParts() const;
143 
150  void *getGlobalBase() const;
151 
158  size_t getGlobalSize() const;
159 
166  void *getBase(std::uint32_t part) const;
167 
174  size_t getSize(std::uint32_t part) const;
175 
182  void *getUserPtr() const;
183 
190  uint64_t getTimestamp() const;
191 
199  bool getNewData() const;
200 
208  bool getIsQueued() const;
209 
217  bool getIsAcquiring() const;
218 
226  bool getIsIncomplete() const;
227 
234  std::string getTLType() const;
235 
244  size_t getSizeFilled() const;
245 
253  size_t getPartDataType(uint32_t part) const;
254 
262  size_t getWidth(std::uint32_t part) const;
263 
271  size_t getHeight(std::uint32_t part) const;
272 
281  size_t getXOffset(std::uint32_t part) const;
282 
291  size_t getYOffset(std::uint32_t part) const;
292 
300  size_t getXPadding(std::uint32_t part) const;
301 
308  size_t getYPadding() const;
309 
317  uint64_t getFrameID() const;
318 
326  bool getImagePresent(std::uint32_t part) const;
327 
334  size_t getPayloadType() const;
335 
345  uint64_t getPixelFormat(std::uint32_t part) const;
346 
355  uint64_t getPixelFormatNamespace(std::uint32_t part) const;
356 
365  uint64_t getPartSourceID(std::uint32_t part) const;
366 
376  size_t getDeliveredImageHeight(std::uint32_t part) const;
377 
384  size_t getDeliveredChunkPayloadSize() const;
385 
394  uint64_t getChunkLayoutID() const;
395 
402  std::string getFilename() const;
403 
410  bool isBigEndian() const;
411 
421  size_t getDataSize() const;
422 
429  uint64_t getTimestampNS() const;
430 
437  bool getDataLargerThanBuffer() const;
438 
445  bool getContainsChunkdata() const;
446 
453  void *getHandle() const;
454 
455  private:
456 
457  Buffer(class Buffer &); // forbidden
458  Buffer &operator=(const Buffer &); // forbidden
459 
461  std::shared_ptr<const GenTLWrapper> gentl;
462  void *buffer;
463  bool multipart;
464 };
465 
466 bool isHostBigEndian();
467 
468 }
469 
470 #endif
size_t getDeliveredImageHeight(std::uint32_t part) const
Returns the number of lines that are delivered in this buffer.
Definition: buffer.cc:429
size_t getDataSize() const
Returns the size of data intended to the written to the buffer the last time it has been filled...
Definition: buffer.cc:484
size_t getYPadding() const
Returns vertical padding of the data in the buffer in bytes.
Definition: buffer.cc:336
Stream * parent
Definition: buffer.h:460
bool multipart
Definition: buffer.h:463
size_t getSizeFilled() const
Returns the number of bytes written into the buffer last time it has been filled. ...
Definition: buffer.cc:252
std::shared_ptr< const GenTLWrapper > gentl
Definition: buffer.h:461
uint64_t getChunkLayoutID() const
Returns the chunk layout id, which serves as an indicator that the chunk layout has changed and the a...
Definition: buffer.cc:449
std::string getFilename() const
Returns the filename in case the payload contains a file.
Definition: buffer.cc:455
void * getHandle() const
Get internal stream handle.
Definition: buffer.cc:531
size_t getXPadding(std::uint32_t part) const
Returns horizontal padding of the data in the buffer in bytes.
Definition: buffer.cc:323
bool getIsQueued() const
Signals if the buffer is associated to the input or output queue.
Definition: buffer.cc:232
size_t getWidth(std::uint32_t part) const
Returns the width of the image in pixel.
Definition: buffer.cc:271
uint64_t getPartSourceID(std::uint32_t part) const
Returns the source id of the specified part.
Definition: buffer.cc:416
size_t getPayloadType() const
Returns the payload type according to PAYLOADTYPE_INFO_IDS.
Definition: buffer.cc:382
PAYLOADTYPE_INFO_IDS
Payload types as taken from GenTL 1.5 definition.
Definition: buffer.h:53
uint64_t getTimestamp() const
Returns the timestamp of the buffer.
Definition: buffer.cc:221
The buffer class encapsulates a Genicam buffer that is provided by a stream.
Definition: buffer.h:115
void * getGlobalBase() const
Returns the global base address of the buffer memory.
Definition: buffer.cc:164
void * getBase(std::uint32_t part) const
Returns the base address of the specified part of the multi-part buffer.
Definition: buffer.cc:174
void * buffer
Definition: buffer.h:462
uint64_t getPixelFormat(std::uint32_t part) const
Returns the pixel format of the specified part as defined in the PFNC.
Definition: buffer.cc:388
size_t getDeliveredChunkPayloadSize() const
Returnes the delivered chung payload size.
Definition: buffer.cc:443
size_t getPartDataType(uint32_t part) const
Returns the data type id of the specified part as defined in PARTDATATYPE_IDS.
Definition: buffer.cc:258
PARTDATATYPE_IDS
Enumeration describing which data type is present in given buffer part as taken from GenTL 1...
Definition: buffer.h:91
bool getContainsChunkdata() const
Returns if the buffer contains chunk data.
Definition: buffer.cc:525
Buffer & operator=(const Buffer &)
uint64_t getTimestampNS() const
Returns the acquisition timestamp of the data in this buffer in ns.
Definition: buffer.cc:489
PIXELFORMAT_NAMESPACE_IDS
Pixelformat namespace IDs as taken from GenTL 1.5 definition.
Definition: buffer.h:75
Buffer(const std::shared_ptr< const GenTLWrapper > &gentl, Stream *parent)
Constructs a buffer class as wrapper around a buffer handle.
Definition: buffer.cc:122
bool isBigEndian() const
Returns if the data is given as big or little endian.
Definition: buffer.cc:460
bool getDataLargerThanBuffer() const
Signals if the memory that was allocated for this buffer is too small.
Definition: buffer.cc:519
bool isHostBigEndian()
Definition: buffer.cc:536
size_t getGlobalSize() const
Returns the global size of the buffer.
Definition: buffer.cc:169
uint64_t getPixelFormatNamespace(std::uint32_t part) const
Returns the pixel format namespace, which preferably should be PIXELFORMAT_NAMESPACE_PFNC_32BIT.
Definition: buffer.cc:402
void * getUserPtr() const
Returns the private data pointer of the GenTL Consumer.
Definition: buffer.cc:216
Definition: buffer.cc:42
bool getIsAcquiring() const
Signals if the buffer is currently being filled with data.
Definition: buffer.cc:237
bool getImagePresent(std::uint32_t part) const
Returns if a 2D, 3D or confidence image is present in the specified part.
Definition: buffer.cc:346
bool getIsIncomplete() const
Signals if the buffer is incomplete due to an error.
Definition: buffer.cc:242
uint64_t getFrameID() const
Returns the sequentially incremented number of the frame.
Definition: buffer.cc:341
size_t getYOffset(std::uint32_t part) const
Returns the vertical offset of the data in the buffer in lines from the image origin to handle areas ...
Definition: buffer.cc:310
bool getNewData() const
Returns if the buffer contains new data.
Definition: buffer.cc:227
void setHandle(void *handle)
Set the buffer handle that this object should manage.
Definition: buffer.cc:130
size_t getXOffset(std::uint32_t part) const
Returns the horizontal offset of the data in the buffer in pixels from the image origin to handle are...
Definition: buffer.cc:297
size_t getHeight(std::uint32_t part) const
Returns the height of the image in pixel.
Definition: buffer.cc:284
The stream class encapsulates a Genicam stream.
Definition: stream.h:55
size_t getSize(std::uint32_t part) const
Returns the size of the specified part of the mult-part buffer.
Definition: buffer.cc:197
std::uint32_t getNumberOfParts() const
Returns the number of parts, excluding chunk data.
Definition: buffer.cc:142
std::string getTLType() const
Returns the type the used transport layer.
Definition: buffer.cc:247


rc_genicam_api
Author(s): Heiko Hirschmueller
autogenerated on Thu Jun 6 2019 19:10:53