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 <GenApi/GenApi.h>
40 #include <GenApi/ChunkAdapter.h>
41 
42 #include <memory>
43 #include <string>
44 
45 namespace rcg
46 {
47 
48 class Stream;
49 class GenTLWrapper;
50 
57 {
58  PAYLOAD_TYPE_UNKNOWN = 0, /* GenTL v1.2 */
59  PAYLOAD_TYPE_IMAGE = 1, /* GenTL v1.2 */
60  PAYLOAD_TYPE_RAW_DATA = 2, /* GenTL v1.2 */
61  PAYLOAD_TYPE_FILE = 3, /* GenTL v1.2 */
62  PAYLOAD_TYPE_CHUNK_DATA = 4, /* GenTL v1.2, Deprecated in GenTL 1.5*/
63  PAYLOAD_TYPE_JPEG = 5, /* GenTL v1.4 */
64  PAYLOAD_TYPE_JPEG2000 = 6, /* GenTL v1.4 */
65  PAYLOAD_TYPE_H264 = 7, /* GenTL v1.4 */
66  PAYLOAD_TYPE_CHUNK_ONLY = 8, /* GenTL v1.4 */
67  PAYLOAD_TYPE_DEVICE_SPECIFIC = 9, /* GenTL v1.4 */
68  PAYLOAD_TYPE_MULTI_PART = 10, /* GenTL v1.5 */
69 
70  PAYLOAD_TYPE_CUSTOM_ID = 1000 /* Starting value for GenTL Producer custom IDs. */
71 };
72 
79 {
80  PIXELFORMAT_NAMESPACE_UNKNOWN = 0, /* GenTL v1.2 */
81  PIXELFORMAT_NAMESPACE_GEV = 1, /* GenTL v1.2 */
82  PIXELFORMAT_NAMESPACE_IIDC = 2, /* GenTL v1.2 */
83  PIXELFORMAT_NAMESPACE_PFNC_16BIT = 3, /* GenTL v1.4 */
84  PIXELFORMAT_NAMESPACE_PFNC_32BIT = 4, /* GenTL v1.4 */
85 
86  PIXELFORMAT_NAMESPACE_CUSTOM_ID = 1000 /* Starting value for GenTL Producer custom IDs. */
87 };
88 
95 {
96  PART_DATATYPE_UNKNOWN = 0, /* Unknown data type */
97  PART_DATATYPE_2D_IMAGE = 1, /* Color or monochrome 2D image. */
98  PART_DATATYPE_2D_PLANE_BIPLANAR = 2, /* Single color plane of a planar 2D image consisting of 2 planes. */
99  PART_DATATYPE_2D_PLANE_TRIPLANAR = 3, /* Single color plane of a planar 2D image consisting of 3 planes. */
100  PART_DATATYPE_2D_PLANE_QUADPLANAR = 4, /* Single color plane of a planar 2D image consisting of 4 planes. */
101  PART_DATATYPE_3D_IMAGE = 5, /* 3D image (pixel coordinates). */
102  PART_DATATYPE_3D_PLANE_BIPLANAR = 6, /* Single plane of a planar 3D image consisting of 2 planes. */
103  PART_DATATYPE_3D_PLANE_TRIPLANAR = 7, /* Single plane of a planar 3D image consisting of 3 planes. */
104  PART_DATATYPE_3D_PLANE_QUADPLANAR = 8, /* Single plane of a planar 3D image consisting of 4 planes. */
105  PART_DATATYPE_CONFIDENCE_MAP = 9, /* Confidence of the individual pixel values. */
106  PART_DATATYPE_CHUNKDATA = 10, /* Chunk data type */
107 
108  PART_DATATYPE_CUSTOM_ID = 1000 /* Starting value for GenTL Producer custom IDs. */
109 };
110 
118 class Buffer
119 {
120  public:
121 
127  Buffer(const std::shared_ptr<const GenTLWrapper> &gentl, Stream *parent);
128  ~Buffer();
129 
137  void setNodemap(const std::shared_ptr<GenApi::CNodeMapRef> nodemap, const std::string &tltype);
138 
146  void setHandle(void *handle);
147 
155  std::uint32_t getNumberOfParts() const;
156 
163  void *getGlobalBase() const;
164 
171  size_t getGlobalSize() const;
172 
179  void *getBase(std::uint32_t part) const;
180 
187  size_t getSize(std::uint32_t part) const;
188 
195  void *getUserPtr() const;
196 
203  uint64_t getTimestamp() const;
204 
212  bool getNewData() const;
213 
221  bool getIsQueued() const;
222 
230  bool getIsAcquiring() const;
231 
239  bool getIsIncomplete() const;
240 
247  std::string getTLType() const;
248 
257  size_t getSizeFilled() const;
258 
266  size_t getPartDataType(uint32_t part) const;
267 
275  size_t getWidth(std::uint32_t part) const;
276 
284  size_t getHeight(std::uint32_t part) const;
285 
294  size_t getXOffset(std::uint32_t part) const;
295 
304  size_t getYOffset(std::uint32_t part) const;
305 
313  size_t getXPadding(std::uint32_t part) const;
314 
321  size_t getYPadding() const;
322 
330  uint64_t getFrameID() const;
331 
339  bool getImagePresent(std::uint32_t part) const;
340 
347  size_t getPayloadType() const;
348 
358  uint64_t getPixelFormat(std::uint32_t part) const;
359 
368  uint64_t getPixelFormatNamespace(std::uint32_t part) const;
369 
378  uint64_t getPartSourceID(std::uint32_t part) const;
379 
389  size_t getDeliveredImageHeight(std::uint32_t part) const;
390 
397  size_t getDeliveredChunkPayloadSize() const;
398 
407  uint64_t getChunkLayoutID() const;
408 
415  std::string getFilename() const;
416 
423  bool isBigEndian() const;
424 
434  size_t getDataSize() const;
435 
442  uint64_t getTimestampNS() const;
443 
450  bool getDataLargerThanBuffer() const;
451 
458  bool getContainsChunkdata() const;
459 
466  void *getHandle() const;
467 
468  private:
469 
470  Buffer(class Buffer &); // forbidden
471  Buffer &operator=(const Buffer &); // forbidden
472 
474  std::shared_ptr<const GenTLWrapper> gentl;
475  void *buffer;
476  size_t payload_type;
477  bool multipart;
478 
479  std::shared_ptr<GenApi::CNodeMapRef> nodemap;
480  std::shared_ptr<GenApi::CChunkAdapter> chunkadapter;
481 };
482 
483 bool isHostBigEndian();
484 
485 }
486 
487 #endif
size_t getDeliveredImageHeight(std::uint32_t part) const
Returns the number of lines that are delivered in this buffer.
Definition: buffer.cc:526
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:586
size_t getYPadding() const
Returns vertical padding of the data in the buffer in bytes.
Definition: buffer.cc:418
Stream * parent
Definition: buffer.h:473
bool multipart
Definition: buffer.h:477
size_t getSizeFilled() const
Returns the number of bytes written into the buffer last time it has been filled. ...
Definition: buffer.cc:314
std::shared_ptr< const GenTLWrapper > gentl
Definition: buffer.h:474
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:551
std::string getFilename() const
Returns the filename in case the payload contains a file.
Definition: buffer.cc:557
void * getHandle() const
Get internal stream handle.
Definition: buffer.cc:638
size_t getXPadding(std::uint32_t part) const
Returns horizontal padding of the data in the buffer in bytes.
Definition: buffer.cc:405
std::shared_ptr< GenApi::CNodeMapRef > nodemap
Definition: buffer.h:479
bool getIsQueued() const
Signals if the buffer is associated to the input or output queue.
Definition: buffer.cc:294
size_t getWidth(std::uint32_t part) const
Returns the width of the image in pixel.
Definition: buffer.cc:333
uint64_t getPartSourceID(std::uint32_t part) const
Returns the source id of the specified part.
Definition: buffer.cc:513
size_t getPayloadType() const
Returns the payload type according to PAYLOADTYPE_INFO_IDS.
Definition: buffer.cc:474
PAYLOADTYPE_INFO_IDS
Payload types as taken from GenTL 1.5 definition.
Definition: buffer.h:56
uint64_t getTimestamp() const
Returns the timestamp of the buffer.
Definition: buffer.cc:278
The buffer class encapsulates a Genicam buffer that is provided by a stream.
Definition: buffer.h:118
void * getGlobalBase() const
Returns the global base address of the buffer memory.
Definition: buffer.cc:221
void * getBase(std::uint32_t part) const
Returns the base address of the specified part of the multi-part buffer.
Definition: buffer.cc:231
void * buffer
Definition: buffer.h:475
uint64_t getPixelFormat(std::uint32_t part) const
Returns the pixel format of the specified part as defined in the PFNC.
Definition: buffer.cc:480
Main include file for using GenApi with smart pointers.
std::shared_ptr< GenApi::CChunkAdapter > chunkadapter
Definition: buffer.h:480
size_t getDeliveredChunkPayloadSize() const
Returnes the delivered chung payload size.
Definition: buffer.cc:545
void setNodemap(const std::shared_ptr< GenApi::CNodeMapRef > nodemap, const std::string &tltype)
Set the device nodemap.
Definition: buffer.cc:143
size_t getPartDataType(uint32_t part) const
Returns the data type id of the specified part as defined in PARTDATATYPE_IDS.
Definition: buffer.cc:320
PARTDATATYPE_IDS
Enumeration describing which data type is present in given buffer part as taken from GenTL 1...
Definition: buffer.h:94
bool getContainsChunkdata() const
Returns if the buffer contains chunk data.
Definition: buffer.cc:627
Buffer & operator=(const Buffer &)
uint64_t getTimestampNS() const
Returns the acquisition timestamp of the data in this buffer in ns.
Definition: buffer.cc:591
PIXELFORMAT_NAMESPACE_IDS
Pixelformat namespace IDs as taken from GenTL 1.5 definition.
Definition: buffer.h:78
Buffer(const std::shared_ptr< const GenTLWrapper > &gentl, Stream *parent)
Constructs a buffer class as wrapper around a buffer handle.
Definition: buffer.cc:127
size_t payload_type
Definition: buffer.h:476
bool isBigEndian() const
Returns if the data is given as big or little endian.
Definition: buffer.cc:562
bool getDataLargerThanBuffer() const
Signals if the memory that was allocated for this buffer is too small.
Definition: buffer.cc:621
bool isHostBigEndian()
Definition: buffer.cc:643
size_t getGlobalSize() const
Returns the global size of the buffer.
Definition: buffer.cc:226
uint64_t getPixelFormatNamespace(std::uint32_t part) const
Returns the pixel format namespace, which preferably should be PIXELFORMAT_NAMESPACE_PFNC_32BIT.
Definition: buffer.cc:499
Declaration of the CChunkAdapter class.
void * getUserPtr() const
Returns the private data pointer of the GenTL Consumer.
Definition: buffer.cc:273
Definition: buffer.cc:47
bool getIsAcquiring() const
Signals if the buffer is currently being filled with data.
Definition: buffer.cc:299
bool getImagePresent(std::uint32_t part) const
Returns if a 2D, 3D or confidence image is present in the specified part.
Definition: buffer.cc:433
bool getIsIncomplete() const
Signals if the buffer is incomplete due to an error.
Definition: buffer.cc:304
uint64_t getFrameID() const
Returns the sequentially incremented number of the frame.
Definition: buffer.cc:428
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:387
bool getNewData() const
Returns if the buffer contains new data.
Definition: buffer.cc:289
void setHandle(void *handle)
Set the buffer handle that this object should manage.
Definition: buffer.cc:168
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:369
size_t getHeight(std::uint32_t part) const
Returns the height of the image in pixel.
Definition: buffer.cc:351
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:254
std::uint32_t getNumberOfParts() const
Returns the number of parts, excluding chunk data.
Definition: buffer.cc:199
std::string getTLType() const
Returns the type the used transport layer.
Definition: buffer.cc:309


rc_genicam_api
Author(s): Heiko Hirschmueller
autogenerated on Wed Mar 17 2021 02:48:40