All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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  uint32_t getNumberOfParts() const;
156 
163  void *getGlobalBase() const;
164 
171  size_t getGlobalSize() const;
172 
179  void *getBase(uint32_t part) const;
180 
187  size_t getSize(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(uint32_t part) const;
276 
284  size_t getHeight(uint32_t part) const;
285 
294  size_t getXOffset(uint32_t part) const;
295 
304  size_t getYOffset(uint32_t part) const;
305 
313  size_t getXPadding(uint32_t part) const;
314 
321  size_t getYPadding() const;
322 
330  uint64_t getFrameID() const;
331 
339  bool getImagePresent(uint32_t part) const;
340 
347  size_t getPayloadType() const;
348 
358  uint64_t getPixelFormat(uint32_t part) const;
359 
368  uint64_t getPixelFormatNamespace(uint32_t part) const;
369 
378  uint64_t getPartSourceID(uint32_t part) const;
379 
387  uint64_t getPartRegionID(uint32_t part) const;
388 
396  uint64_t getPartDataPurposeID(uint32_t part) const;
397 
407  size_t getDeliveredImageHeight(uint32_t part) const;
408 
415  size_t getDeliveredChunkPayloadSize() const;
416 
425  uint64_t getChunkLayoutID() const;
426 
433  std::string getFilename() const;
434 
441  bool isBigEndian() const;
442 
452  size_t getDataSize() const;
453 
460  uint64_t getTimestampNS() const;
461 
468  bool getDataLargerThanBuffer() const;
469 
476  bool getContainsChunkdata() const;
477 
484  void *getHandle() const;
485 
486  private:
487 
488  Buffer(class Buffer &); // forbidden
489  Buffer &operator=(const Buffer &); // forbidden
490 
492  std::shared_ptr<const GenTLWrapper> gentl;
493  void *buffer;
494  size_t payload_type;
495  bool multipart;
496 
497  std::shared_ptr<GenApi::CNodeMapRef> nodemap;
498  std::shared_ptr<GenApi::CChunkAdapter> chunkadapter;
499 };
500 
501 bool isHostBigEndian();
502 
503 }
504 
505 #endif
rcg::PIXELFORMAT_NAMESPACE_GEV
@ PIXELFORMAT_NAMESPACE_GEV
Definition: buffer.h:81
rcg::Buffer::operator=
Buffer & operator=(const Buffer &)
rcg::PART_DATATYPE_CHUNKDATA
@ PART_DATATYPE_CHUNKDATA
Definition: buffer.h:106
rcg::PIXELFORMAT_NAMESPACE_IDS
PIXELFORMAT_NAMESPACE_IDS
Pixelformat namespace IDs as taken from GenTL 1.5 definition.
Definition: buffer.h:78
rcg::Buffer::getDeliveredImageHeight
size_t getDeliveredImageHeight(uint32_t part) const
Returns the number of lines that are delivered in this buffer.
Definition: buffer.cc:598
rcg::Buffer::getChunkLayoutID
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:630
rcg::Buffer::getGlobalSize
size_t getGlobalSize() const
Returns the global size of the buffer.
Definition: buffer.cc:230
rcg::PAYLOAD_TYPE_UNKNOWN
@ PAYLOAD_TYPE_UNKNOWN
Definition: buffer.h:58
GenApi.h
Main include file for using GenApi with smart pointers.
rcg::PIXELFORMAT_NAMESPACE_UNKNOWN
@ PIXELFORMAT_NAMESPACE_UNKNOWN
Definition: buffer.h:80
rcg::PAYLOAD_TYPE_DEVICE_SPECIFIC
@ PAYLOAD_TYPE_DEVICE_SPECIFIC
Definition: buffer.h:67
rcg::isHostBigEndian
bool isHostBigEndian()
Definition: buffer.cc:722
rcg::Buffer::setNodemap
void setNodemap(const std::shared_ptr< GenApi::CNodeMapRef > nodemap, const std::string &tltype)
Set the device nodemap.
Definition: buffer.cc:146
rcg::Buffer::getImagePresent
bool getImagePresent(uint32_t part) const
Returns if a 2D, 3D or confidence image is present in the specified part.
Definition: buffer.cc:472
rcg::PAYLOAD_TYPE_IMAGE
@ PAYLOAD_TYPE_IMAGE
Definition: buffer.h:59
rcg::Buffer
The buffer class encapsulates a Genicam buffer that is provided by a stream.
Definition: buffer.h:118
rcg::Buffer::getPartDataType
size_t getPartDataType(uint32_t part) const
Returns the data type id of the specified part as defined in PARTDATATYPE_IDS.
Definition: buffer.cc:331
rcg::Buffer::getDeliveredChunkPayloadSize
size_t getDeliveredChunkPayloadSize() const
Returnes the delivered chung payload size.
Definition: buffer.cc:624
rcg::PAYLOADTYPE_INFO_IDS
PAYLOADTYPE_INFO_IDS
Payload types as taken from GenTL 1.5 definition.
Definition: buffer.h:56
rcg::Buffer::getTLType
std::string getTLType() const
Returns the type the used transport layer.
Definition: buffer.cc:320
rcg::Buffer::parent
Stream * parent
Definition: buffer.h:491
rcg::Buffer::getFilename
std::string getFilename() const
Returns the filename in case the payload contains a file.
Definition: buffer.cc:636
rcg::Buffer::setHandle
void setHandle(void *handle)
Set the buffer handle that this object should manage.
Definition: buffer.cc:171
rcg::PART_DATATYPE_3D_IMAGE
@ PART_DATATYPE_3D_IMAGE
Definition: buffer.h:101
rcg::PART_DATATYPE_3D_PLANE_QUADPLANAR
@ PART_DATATYPE_3D_PLANE_QUADPLANAR
Definition: buffer.h:104
rcg::Stream
The stream class encapsulates a Genicam stream.
Definition: stream.h:55
rcg::Buffer::payload_type
size_t payload_type
Definition: buffer.h:494
rcg::Buffer::getTimestampNS
uint64_t getTimestampNS() const
Returns the acquisition timestamp of the data in this buffer in ns.
Definition: buffer.cc:670
rcg::Buffer::getHandle
void * getHandle() const
Get internal stream handle.
Definition: buffer.cc:717
rcg::Buffer::getPartRegionID
uint64_t getPartRegionID(uint32_t part) const
Returns the region id of the specified part.
Definition: buffer.cc:572
rcg::Buffer::getNumberOfParts
uint32_t getNumberOfParts() const
Returns the number of parts, excluding chunk data.
Definition: buffer.cc:203
rcg::Buffer::getYPadding
size_t getYPadding() const
Returns vertical padding of the data in the buffer in bytes.
Definition: buffer.cc:457
rcg::PART_DATATYPE_CONFIDENCE_MAP
@ PART_DATATYPE_CONFIDENCE_MAP
Definition: buffer.h:105
rcg::Buffer::getUserPtr
void * getUserPtr() const
Returns the private data pointer of the GenTL Consumer.
Definition: buffer.cc:277
rcg::Buffer::getIsIncomplete
bool getIsIncomplete() const
Signals if the buffer is incomplete due to an error.
Definition: buffer.cc:315
rcg
Definition: buffer.cc:47
rcg::Buffer::getContainsChunkdata
bool getContainsChunkdata() const
Returns if the buffer contains chunk data.
Definition: buffer.cc:706
rcg::PAYLOAD_TYPE_JPEG
@ PAYLOAD_TYPE_JPEG
Definition: buffer.h:63
rcg::Buffer::getDataLargerThanBuffer
bool getDataLargerThanBuffer() const
Signals if the memory that was allocated for this buffer is too small.
Definition: buffer.cc:700
rcg::Buffer::getTimestamp
uint64_t getTimestamp() const
Returns the timestamp of the buffer.
Definition: buffer.cc:282
rcg::PART_DATATYPE_2D_PLANE_BIPLANAR
@ PART_DATATYPE_2D_PLANE_BIPLANAR
Definition: buffer.h:98
rcg::Buffer::getHeight
size_t getHeight(uint32_t part) const
Returns the height of the image in pixel.
Definition: buffer.cc:369
rcg::Buffer::~Buffer
~Buffer()
Definition: buffer.cc:138
rcg::PIXELFORMAT_NAMESPACE_PFNC_32BIT
@ PIXELFORMAT_NAMESPACE_PFNC_32BIT
Definition: buffer.h:84
rcg::Buffer::getPayloadType
size_t getPayloadType() const
Returns the payload type according to PAYLOADTYPE_INFO_IDS.
Definition: buffer.cc:513
rcg::PAYLOAD_TYPE_CHUNK_ONLY
@ PAYLOAD_TYPE_CHUNK_ONLY
Definition: buffer.h:66
rcg::Buffer::getFrameID
uint64_t getFrameID() const
Returns the sequentially incremented number of the frame.
Definition: buffer.cc:467
rcg::PARTDATATYPE_IDS
PARTDATATYPE_IDS
Enumeration describing which data type is present in given buffer part as taken from GenTL 1....
Definition: buffer.h:94
rcg::PAYLOAD_TYPE_JPEG2000
@ PAYLOAD_TYPE_JPEG2000
Definition: buffer.h:64
rcg::PIXELFORMAT_NAMESPACE_CUSTOM_ID
@ PIXELFORMAT_NAMESPACE_CUSTOM_ID
Definition: buffer.h:86
rcg::Buffer::getSize
size_t getSize(uint32_t part) const
Returns the size of the specified part of the mult-part buffer.
Definition: buffer.cc:258
rcg::Buffer::getIsAcquiring
bool getIsAcquiring() const
Signals if the buffer is currently being filled with data.
Definition: buffer.cc:310
rcg::Buffer::getPartDataPurposeID
uint64_t getPartDataPurposeID(uint32_t part) const
Returns the data purpose id of the specified part.
Definition: buffer.cc:585
rcg::Buffer::getXOffset
size_t getXOffset(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:394
rcg::Buffer::getSizeFilled
size_t getSizeFilled() const
Returns the number of bytes written into the buffer last time it has been filled.
Definition: buffer.cc:325
rcg::PART_DATATYPE_2D_IMAGE
@ PART_DATATYPE_2D_IMAGE
Definition: buffer.h:97
rcg::Buffer::getYOffset
size_t getYOffset(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:419
rcg::PAYLOAD_TYPE_MULTI_PART
@ PAYLOAD_TYPE_MULTI_PART
Definition: buffer.h:68
rcg::Buffer::isBigEndian
bool isBigEndian() const
Returns if the data is given as big or little endian.
Definition: buffer.cc:641
rcg::PART_DATATYPE_3D_PLANE_TRIPLANAR
@ PART_DATATYPE_3D_PLANE_TRIPLANAR
Definition: buffer.h:103
rcg::PAYLOAD_TYPE_CUSTOM_ID
@ PAYLOAD_TYPE_CUSTOM_ID
Definition: buffer.h:70
rcg::Buffer::Buffer
Buffer(const std::shared_ptr< const GenTLWrapper > &gentl, Stream *parent)
Constructs a buffer class as wrapper around a buffer handle.
Definition: buffer.cc:130
rcg::Buffer::getXPadding
size_t getXPadding(uint32_t part) const
Returns horizontal padding of the data in the buffer in bytes.
Definition: buffer.cc:444
rcg::PIXELFORMAT_NAMESPACE_PFNC_16BIT
@ PIXELFORMAT_NAMESPACE_PFNC_16BIT
Definition: buffer.h:83
rcg::PAYLOAD_TYPE_H264
@ PAYLOAD_TYPE_H264
Definition: buffer.h:65
rcg::Buffer::gentl
std::shared_ptr< const GenTLWrapper > gentl
Definition: buffer.h:492
rcg::Buffer::getGlobalBase
void * getGlobalBase() const
Returns the global base address of the buffer memory.
Definition: buffer.cc:225
rcg::Buffer::chunkadapter
std::shared_ptr< GenApi::CChunkAdapter > chunkadapter
Definition: buffer.h:498
rcg::Buffer::getDataSize
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:665
rcg::PAYLOAD_TYPE_RAW_DATA
@ PAYLOAD_TYPE_RAW_DATA
Definition: buffer.h:60
rcg::Buffer::getNewData
bool getNewData() const
Returns if the buffer contains new data.
Definition: buffer.cc:300
rcg::Buffer::nodemap
std::shared_ptr< GenApi::CNodeMapRef > nodemap
Definition: buffer.h:497
rcg::PART_DATATYPE_CUSTOM_ID
@ PART_DATATYPE_CUSTOM_ID
Definition: buffer.h:108
rcg::PART_DATATYPE_3D_PLANE_BIPLANAR
@ PART_DATATYPE_3D_PLANE_BIPLANAR
Definition: buffer.h:102
rcg::Buffer::multipart
bool multipart
Definition: buffer.h:495
rcg::PART_DATATYPE_2D_PLANE_QUADPLANAR
@ PART_DATATYPE_2D_PLANE_QUADPLANAR
Definition: buffer.h:100
rcg::PAYLOAD_TYPE_CHUNK_DATA
@ PAYLOAD_TYPE_CHUNK_DATA
Definition: buffer.h:62
rcg::Buffer::getIsQueued
bool getIsQueued() const
Signals if the buffer is associated to the input or output queue.
Definition: buffer.cc:305
rcg::Buffer::getWidth
size_t getWidth(uint32_t part) const
Returns the width of the image in pixel.
Definition: buffer.cc:344
rcg::PART_DATATYPE_UNKNOWN
@ PART_DATATYPE_UNKNOWN
Definition: buffer.h:96
rcg::PAYLOAD_TYPE_FILE
@ PAYLOAD_TYPE_FILE
Definition: buffer.h:61
ChunkAdapter.h
Declaration of the CChunkAdapter class.
rcg::Buffer::getPartSourceID
uint64_t getPartSourceID(uint32_t part) const
Returns the source id of the specified part.
Definition: buffer.cc:559
rcg::PART_DATATYPE_2D_PLANE_TRIPLANAR
@ PART_DATATYPE_2D_PLANE_TRIPLANAR
Definition: buffer.h:99
rcg::PIXELFORMAT_NAMESPACE_IIDC
@ PIXELFORMAT_NAMESPACE_IIDC
Definition: buffer.h:82
rcg::Buffer::buffer
void * buffer
Definition: buffer.h:493
rcg::Buffer::getBase
void * getBase(uint32_t part) const
Returns the base address of the specified part of the multi-part buffer.
Definition: buffer.cc:235
rcg::Buffer::getPixelFormat
uint64_t getPixelFormat(uint32_t part) const
Returns the pixel format of the specified part as defined in the PFNC.
Definition: buffer.cc:519
rcg::Buffer::getPixelFormatNamespace
uint64_t getPixelFormatNamespace(uint32_t part) const
Returns the pixel format namespace, which preferably should be PIXELFORMAT_NAMESPACE_PFNC_32BIT.
Definition: buffer.cc:545


rc_genicam_api
Author(s): Heiko Hirschmueller
autogenerated on Wed Dec 4 2024 03:10:11