GrabResultData.h 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. //-----------------------------------------------------------------------------
  2. // Basler pylon SDK
  3. // Copyright (c) 2010-2021 Basler AG
  4. // http://www.baslerweb.com
  5. // Author: Andreas Gau
  6. //-----------------------------------------------------------------------------
  7. /*!
  8. \file
  9. \brief Contains a class that makes the data for one grabbed buffer available.
  10. */
  11. #ifndef INCLUDED_GRABRESULTDATA_H_1758952
  12. #define INCLUDED_GRABRESULTDATA_H_1758952
  13. #include <pylon/Platform.h>
  14. #ifdef _MSC_VER
  15. # pragma pack(push, PYLON_PACKING)
  16. #endif /* _MSC_VER */
  17. #include <pylon/PylonBase.h>
  18. #include <pylon/PixelType.h>
  19. #include <pylon/PayloadType.h>
  20. #include <GenApi/GenApiDll.h> // [temporary] namespace alias
  21. #include <GenICamFwd.h>
  22. namespace Pylon
  23. {
  24. // Forward declaration
  25. class CPylonDataContainer;
  26. class CPylonDataComponent;
  27. /** \addtogroup Pylon_InstantCameraApiGeneric
  28. * @{
  29. */
  30. /*!
  31. \class CGrabResultData
  32. \brief Makes the data for one grabbed buffer available.
  33. */
  34. class PYLONBASE_API CGrabResultData
  35. {
  36. public:
  37. /// Returns true if an image has been grabbed successfully and false in the case of an error.
  38. bool GrabSucceeded() const;
  39. /// This method returns a description of the error if GrabSucceeded() returns false due to an error.
  40. String_t GetErrorDescription() const;
  41. /// This method returns the error code if GrabSucceeded() returns false due to an error.
  42. uint32_t GetErrorCode() const;
  43. /// Get the current payload type.
  44. EPayloadType GetPayloadType() const;
  45. /// Get the current pixel type.
  46. EPixelType GetPixelType() const;
  47. /// Get the current number of columns.
  48. uint32_t GetWidth() const;
  49. /// Get the current number of rows expressed as number of pixels.
  50. uint32_t GetHeight() const;
  51. /// Get the current starting column.
  52. uint32_t GetOffsetX() const;
  53. /// Get the current starting row.
  54. uint32_t GetOffsetY() const;
  55. /// Get the number of extra data at the end of each row in bytes.
  56. uint32_t GetPaddingX() const;
  57. /// Get the number of extra data at the end of the image data in bytes.
  58. uint32_t GetPaddingY() const;
  59. /// Get the pointer to the buffer.
  60. /*!
  61. If the chunk data feature is activated for the device, chunk data is appended to the image data.
  62. When writing past the image section while performing image processing, the chunk data will be corrupted.
  63. */
  64. void* GetBuffer() const;
  65. /// Get the current payload size in bytes.
  66. size_t GetPayloadSize() const;
  67. /// Get the size of the buffer returned by GetBuffer() in bytes.
  68. size_t GetBufferSize() const;
  69. /// Get the block ID of the grabbed frame (camera device specific).
  70. /*!
  71. \par IEEE 1394 Camera Devices
  72. The value of Block ID is always UINT64_MAX.
  73. \par GigE Camera Devices
  74. The sequence number starts with 1 and
  75. wraps at 65535. The value 0 has a special meaning and indicates
  76. that this feature is not supported by the camera.
  77. \par USB Camera Devices
  78. The sequence number starts with 0 and uses the full 64 Bit range.
  79. \attention A block ID with the value UINT64_MAX indicates that the block ID is invalid and must not be used.
  80. */
  81. uint64_t GetBlockID() const;
  82. /// Get the camera specific tick count (camera device specific).
  83. /*!
  84. This describes when the image exposure was started.
  85. Cameras that do not support this feature return zero. If supported, this
  86. can be used to determine which image AOIs were acquired simultaneously.
  87. */
  88. uint64_t GetTimeStamp() const;
  89. /// Get the stride in bytes.
  90. /*
  91. Uses Pylon::ComputeStride to compute the stride from the result data.
  92. \return The stride in byte.
  93. \pre The preconditions of Pylon::ComputeStride must be met.
  94. \error
  95. Throws an exception if the stride value cannot be computed from the result data.
  96. */
  97. bool GetStride( size_t& strideBytes ) const;
  98. /// Get the size of the image in byte.
  99. /*
  100. Uses Pylon::ComputeBufferSize to compute the stride from the result data.
  101. PaddingY is not taken into account.
  102. \return The buffer size in byte.
  103. \pre The preconditions of Pylon::ComputeBufferSize must be met.
  104. \error
  105. Throws an exception if the buffer size cannot be computed from the result data.
  106. */
  107. size_t GetImageSize() const;
  108. /// Get the context value assigned to the camera object. The context is attached to the result when it is retrieved.
  109. intptr_t GetCameraContext() const;
  110. /// Get the ID of the grabbed image.
  111. /*! Always returns a number larger than 0. The counting starts with 1 and is never reset during the lifetime of the Instant Camera object. */
  112. int64_t GetID() const;
  113. /// Get the number of the image. This number is incremented when an image is retrieved using CInstantCamera::RetrieveResult().
  114. /*! Always returns a number larger than 0. The counting starts with 1 and is reset with every call to CInstantCamera::StartGrabbing(). */
  115. int64_t GetImageNumber() const;
  116. /// Get the number of skipped images before this image.
  117. /*!
  118. This value can be larger than 0 if EGrabStrategy_LatestImageOnly grab strategy or GrabStrategy_LatestImages grab strategy is used.
  119. Always returns a number larger than or equal 0. This number does not include the number of images lost in case of a buffer underrun in the driver.
  120. */
  121. int64_t GetNumberOfSkippedImages() const;
  122. /// Returns true if chunk data is available.
  123. /*!
  124. This is the case if the chunk mode is enabled for the camera device.
  125. The parameter CInstantCamera::ChunkNodeMapsEnable of the used Instant Camera object is set to true (default setting).
  126. Chunk data node maps are supported by the Transport Layer of the camera device.
  127. */
  128. bool IsChunkDataAvailable() const;
  129. /// Get the reference to the chunk data node map connected to the result.
  130. /*! An empty node map is returned when the device does not support this feature or when chunks are disabled. */
  131. GenApi::INodeMap& GetChunkDataNodeMap() const;
  132. /// Checks if buffer has a CRC attached. This needs not be activated for the device. See the PayloadCRC16 chunk.
  133. /* The chunk feature must be supported and activated, otherwise false is returned. */
  134. bool HasCRC() const;
  135. /// Checks CRC sum of buffer, returns true if CRC sum is OK.
  136. /*
  137. \error
  138. Throws an exception if GetHasCRC() is false and chunks are activated.
  139. */
  140. bool CheckCRC() const;
  141. /// Get the context value assigned to the buffer. The context is set when CInstamtCamera is using a custom buffer factory.
  142. intptr_t GetBufferContext() const;
  143. /// Returns the grab result as a CPylonDataContainer.
  144. CPylonDataContainer GetDataContainer() const;
  145. /// \copydoc Pylon::CPylonDataContainer::GetDataComponentCount()
  146. size_t GetDataComponentCount() const;
  147. /// \copydoc Pylon::CPylonDataContainer::GetDataComponent()
  148. CPylonDataComponent GetDataComponent( size_t index );
  149. /// Internal use only.
  150. class CGrabResultDataImpl;
  151. CGrabResultDataImpl* GetGrabResultDataImpl();
  152. virtual ~CGrabResultData();
  153. private:
  154. ///The grab result data object can not be copied.
  155. CGrabResultData( const CGrabResultData& );
  156. ///The grab result data object can not be copied.
  157. void operator = ( const CGrabResultData& );
  158. protected:
  159. /// Internal use only. The grab result data class should only be created by the instant camera class.
  160. friend class CInstantCamera;
  161. CGrabResultData();
  162. private:
  163. virtual void Destroy();
  164. virtual void Initialize();
  165. // Internal use only. Subject to change without notice.
  166. friend class CGrabResultDataFactory;
  167. CGrabResultDataImpl* m_pImpl;
  168. // The grab result data
  169. const void*& m_pBuffer;
  170. size_t& m_bufferSize;
  171. bool& m_grabSucceeded;
  172. EPayloadType& m_payloadType;
  173. EPixelType& m_pixelType;
  174. uint64_t& m_timeStamp;
  175. uint32_t& m_width;
  176. uint32_t& m_height;
  177. uint32_t& m_offsetX;
  178. uint32_t& m_offsetY;
  179. uint32_t& m_paddingX;
  180. uint32_t& m_paddingY;
  181. uint64_t& m_payloadSize;
  182. uint32_t& m_errorCode;
  183. String_t& m_errorDescription;
  184. intptr_t& m_cameraContext;
  185. int64_t& m_ID;
  186. int64_t& m_imageNumber;
  187. int64_t& m_skippedImageCount;
  188. intptr_t& m_bufferContext;
  189. uint64_t& m_blockId;
  190. };
  191. /**
  192. * @}
  193. */
  194. }
  195. #ifdef _MSC_VER
  196. # pragma pack(pop)
  197. #endif /* _MSC_VER */
  198. #endif /* INCLUDED_GRABRESULTDATA_H_1758952 */