ImageDecompressor.h 37 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631
  1. //-----------------------------------------------------------------------------
  2. // Basler pylon SDK
  3. // Copyright (c) 2019-2021 Basler AG
  4. // http://www.baslerweb.com
  5. // Author: MP
  6. //-----------------------------------------------------------------------------
  7. /**
  8. * \file
  9. * \brief Declaration of the CImageDecompressor class
  10. */
  11. #pragma once
  12. #ifndef INCLUDED_IMAGEDECOMPRESSOR_H_C5305647
  13. #define INCLUDED_IMAGEDECOMPRESSOR_H_C5305647
  14. #include <pylon/Platform.h>
  15. #include <GenApi/INodeMap.h>
  16. #include <pylon/PylonUtility.h>
  17. #include <pylon/ReusableImage.h>
  18. #include <pylon/Result.h>
  19. #include <pylon/PixelType.h>
  20. #include <pylon/GrabResultPtr.h>
  21. namespace Pylon
  22. {
  23. #ifdef _MSC_VER
  24. # pragma pack(push, PYLON_PACKING)
  25. #endif /* _MSC_VER */
  26. /*!
  27. \enum ECompressionStatus
  28. \brief Status of a grab buffer/result with compressed data.
  29. It is possible that images could not be compressed properly by the camera (if the amount of data required for
  30. compressing an image exceeds the desired compression ratio). If an image was compressed successfully, it will
  31. have the compression status CompressionStatus_Ok.
  32. */
  33. enum ECompressionStatus
  34. {
  35. CompressionStatus_Ok, //!< Buffer was compressed properly.
  36. CompressionStatus_BufferOverflow, //!< Size of compressed image exceeded desired compression ratio.
  37. CompressionStatus_Error //!< Generic error.
  38. };
  39. /*!
  40. \enum EEndianness
  41. \brief Endianness for parsing the grab buffer/result as defined for the camera technology used.
  42. If not known, Endianness_Auto can be used to detect the endianness automatically. However, this may take longer.
  43. */
  44. enum EEndianness
  45. {
  46. Endianness_Little, //!< Little endian (e.g., as used in USB3 Vision).
  47. Endianness_Big, //!< Big endian (e.g., as used in GigE Vision).
  48. Endianness_Auto //!< Try to detect endianness automatically.
  49. };
  50. /*!
  51. \struct CompressionInfo_t
  52. \brief The struct containing information about a grab buffer/result.
  53. You can find more information about the usage of this struct in the description of
  54. the CImageDecompressor class.
  55. */
  56. struct PYLONUTILITY_API CompressionInfo_t
  57. {
  58. bool hasCompressedImage; ///< True if grab buffer/result provided contains a compressed image (otherwise false if buffer/result is already decompressed).
  59. ECompressionStatus compressionStatus; ///< Status of compression (see ECompressionStatus).
  60. bool lossy; ///< True if image was compressed lossily (otherwise false if it was compressed losslessly).
  61. EPixelType pixelType; ///< Pixel type of compressed image.
  62. size_t width; ///< Width (in pixels) of compressed image.
  63. size_t height; ///< Height (in pixels) of compressed image.
  64. size_t offsetX; ///< X offset (in pixels) of compressed image.
  65. size_t offsetY; ///< Y offset (in pixels) of compressed image.
  66. size_t paddingX; ///< X padding (line padding; in bytes) of compressed image.
  67. size_t paddingY; ///< Y padding (image padding; in bytes) of compressed image.
  68. size_t decompressedImageSize; ///< Size (in bytes) required for decompressed image (only valid if hasCompressedImage is true).
  69. size_t decompressedPayloadSize; ///< Size (in bytes; including chunk data) required for decompressed payload (only valid if hasCompressedImage is true).
  70. /*!
  71. \brief Creates and initializes a compression info struct.
  72. \error
  73. Does not throw C++ exceptions.
  74. */
  75. CompressionInfo_t();
  76. };
  77. /*!
  78. \enum ECompressionMode
  79. \brief Mode used for transferring images.
  80. The compression mode can have three states. Either compression is disabled in the camera (CompressionMode_Off)
  81. or the camera compresses the images in one of two ways (CompressionMode_BaslerLossless or CompressionMode_BaslerFixRatio).
  82. */
  83. enum ECompressionMode
  84. {
  85. CompressionMode_Off, //!< Images are transferred uncompressed.
  86. CompressionMode_BaslerLossless, //!< Images are transferred with Basler lossless compression.
  87. CompressionMode_BaslerFixRatio //!< Images are transferred with Basler fixed ratio compression (which may lead to lossily compressed images).
  88. };
  89. /*!
  90. \class CImageDecompressor
  91. \brief Provides convenient access to cameras that support image compression and helps with decompressing these images.
  92. A decompressor requires a compression descriptor in order to be able to decompress images. You can set
  93. a compression descriptor via the constructor or the SetCompressionDescriptor methods (in both cases,
  94. either using the node map or manually).
  95. A compression descriptor can be identified via a hash. This hash can be used to identify the matching
  96. compression descriptor for a particular compressed image. It can be computed using the
  97. ComputeCompressionDescriptorHash method or retrieved from the camera, decompressor, or a grab buffer/result
  98. using one of the GetCompressionDescriptorHash methods.
  99. Grab buffers/results may contain different kinds of data. You can use the
  100. decompressor's GetCompressionInfo methods to distinguish between them. For that to work, a
  101. grab buffer/result must have been received successfully and it must contain the
  102. payload type chunk (for grab results you can get the payload type using the
  103. GetPayloadType method).
  104. If compression info for the grab buffer/result provided is available,
  105. GetCompressionInfo returns true and you will receive the compression info
  106. via the CompressionInfo_t struct.
  107. If the field hasCompressedImage in the struct is true, the grab buffer/result
  108. contains a compressed image. In this case, you should check the compressionStatus
  109. field in the struct to check whether the camera was able to compress
  110. the image properly. The camera can't compress an image if the amount of
  111. data required for compressing the image exceeds the desired compression ratio.
  112. The image can be decompressed if compressionStatus is CompressionStatus_Ok.
  113. If the field hasCompressedImage in the struct is false, the grab buffer/result
  114. contains an already decompressed image. In this case, the decompressedImageSize
  115. and decompressedPayloadSize fields will not be used. All other fields contain
  116. information about the decompressed data.
  117. */
  118. class PYLONUTILITY_API CImageDecompressor
  119. {
  120. public:
  121. /*!
  122. \brief Creates an empty decompressor without compression descriptor.
  123. This constructor does not initialize the decompressor with a compression descriptor. You will have to
  124. initialize the decompressor first by using one of the SetCompressionDescriptor methods in order to be
  125. able to decompress images. You will get an exception if you access methods that require the decompressor
  126. to be initialized (see method descriptions for which methods are affected by that precondition).
  127. \error
  128. Throws an exception if no memory can be allocated.
  129. */
  130. CImageDecompressor();
  131. /*!
  132. \brief Creates a decompressor by copying from another decompressor.
  133. \param[in] imageDecompressor Decompressor to copy from during initialization.
  134. \error
  135. Throws an exception if no memory can be allocated.
  136. */
  137. explicit CImageDecompressor( const CImageDecompressor& imageDecompressor );
  138. /*!
  139. \brief Creates a decompressor and initializes it with the compression descriptor provided.
  140. \param[in] pCompressionDescriptor Pointer to the compression descriptor. This parameter must not be NULL.
  141. \param[in] sizeCompressionDescriptor Size of the data (in bytes) of the compression descriptor.
  142. \error
  143. Throws an exception if no memory can be allocated or the compression descriptor provided is invalid (e.g., because it is corrupt)
  144. or incompatible (e.g., because a compression descriptor of a newer compression implementation is passed).
  145. */
  146. CImageDecompressor( const void* pCompressionDescriptor, size_t sizeCompressionDescriptor );
  147. /*!
  148. \brief Creates a decompressor and initializes it with a compression descriptor that is retrieved from the camera's node map.
  149. \param[in] nodeMap Node map of the camera to be used for retrieving the compression descriptor.
  150. \error
  151. Throws an exception if no memory can be allocated or no proper compression descriptor can be retrieved from the camera.
  152. */
  153. explicit CImageDecompressor( GenApi::INodeMap& nodeMap );
  154. /*!
  155. \brief Destroys the decompressor instance.
  156. \error
  157. Does not throw C++ exceptions.
  158. \threading
  159. This method is thread-safe.
  160. */
  161. ~CImageDecompressor();
  162. /*!
  163. \brief Determines whether the decompressor already has a compression descriptor.
  164. \return Returns true if the decompressor is already initialized with a compression descriptor or false otherwise.
  165. \error
  166. Does not throw C++ exceptions.
  167. \threading
  168. This method is thread-safe.
  169. */
  170. bool HasCompressionDescriptor() const;
  171. /*!
  172. \brief Resets the compression descriptor in the decompressor.
  173. \note After calling this method, no images can be decompressed by the decompressor because it is
  174. back in uninitialized state.
  175. \error
  176. Does not throw C++ exceptions.
  177. \threading
  178. This method is thread-safe.
  179. */
  180. void ResetCompressionDescriptor();
  181. /*!
  182. \brief Initializes a decompressor with the compression descriptor provided.
  183. \param[in] pCompressionDescriptor Pointer to the compression descriptor. This parameter must not be NULL.
  184. \param[in] sizeCompressionDescriptor Size of the data (in bytes) of the compression descriptor.
  185. \error
  186. Throws an exception if no memory can be allocated or the compression descriptor provided is invalid (e.g., because it is corrupt)
  187. or incompatible (e.g., because a compression descriptor of a newer compression implementation is passed).
  188. \threading
  189. This method is thread-safe.
  190. */
  191. void SetCompressionDescriptor( const void* pCompressionDescriptor, size_t sizeCompressionDescriptor );
  192. /*!
  193. \brief Initializes a decompressor with a compression descriptor that is retrieved from the camera's node map.
  194. \param[in] nodeMap Node map of the camera to be used for retrieving the compression descriptor.
  195. \error
  196. Throws an exception if no memory can be allocated or no proper compression descriptor can be retrieved from the camera.
  197. \threading
  198. This method is thread-safe.
  199. */
  200. void SetCompressionDescriptor( GenApi::INodeMap& nodeMap );
  201. /*!
  202. \brief Retrieves the current compression mode from the camera's node map.
  203. This indicates which kind of compression is active or whether compression is not enabled (or unavailable).
  204. \param[in] nodeMap Node map of the camera to be used for retrieving the compression mode.
  205. \return Returns the current compression mode of the camera.
  206. \error
  207. Throws an exception if an error is encountered while determining the compression mode.
  208. \threading
  209. This method is thread-safe.
  210. */
  211. static ECompressionMode GetCompressionMode( GenApi::INodeMap& nodeMap );
  212. /*!
  213. \brief Gets the currently set compression descriptor.
  214. This method requires that a compression descriptor has been set previously via the constructor or
  215. the SetCompressionDescriptor methods. You can determine this via the HasCompressionDescriptor method.
  216. \param[out] pCompressionDescriptor Pointer to the buffer that will receive the compression descriptor or
  217. NULL if you only want to get the size of the buffer for buffer allocation.
  218. \param[in,out] pSizeCompressionDescriptor On input, the variable specifies the size of the buffer (in bytes)
  219. for the compression descriptor (if pCompressionDescriptor is not NULL).
  220. On output, the variable will receive the actual buffer size required for the current
  221. compression descriptor.
  222. This parameter must not be NULL.
  223. \error
  224. Throws an exception if the decompressor has no compression descriptor set or the input parameters are
  225. invalid (e.g., if the size provided is not sufficient to hold the compression descriptor).
  226. \threading
  227. This method is thread-safe.
  228. */
  229. void GetCompressionDescriptor( void* pCompressionDescriptor, size_t* pSizeCompressionDescriptor ) const;
  230. /*!
  231. \brief Gets the current compression descriptor from the camera's node map.
  232. This method requires image compression to be enabled in the camera. You can determine this via the
  233. GetCompressionMode method.
  234. \param[out] pCompressionDescriptor Pointer to the buffer that will receive the compression descriptor or
  235. NULL if you only want to get the size of the buffer for buffer allocation.
  236. \param[in,out] pSizeCompressionDescriptor On input, the variable specifies the size of the buffer (in bytes)
  237. for the compression descriptor (if pCompressionDescriptor is not NULL).
  238. On output, the variable will receive the actual buffer size required for the current
  239. compression descriptor.
  240. This parameter must not be NULL.
  241. \param[in] nodeMap Node map of the camera to be used for retrieving the compression descriptor.
  242. \error
  243. Throws an exception if compression is not enabled in the camera (or unavailable) or the input parameters are
  244. invalid (e.g., if the size provided is not sufficient to hold the compression descriptor).
  245. \threading
  246. This method is thread-safe.
  247. */
  248. static void GetCompressionDescriptor( void* pCompressionDescriptor, size_t* pSizeCompressionDescriptor, GenApi::INodeMap& nodeMap );
  249. /*!
  250. \brief Gets compression information about a grab buffer.
  251. \param[out] compressionInfo Reference to the struct that will receive the compression information if the grab buffer contains such information.
  252. \param[in] pGrabBuffer Pointer to the grab buffer that holds the compressed data. This parameter must not be NULL.
  253. \param[in] payloadSize Payload size (in bytes) of the data received (must be less or equal to the size of the grab buffer).
  254. \param[in] endianness Endianness of the grab buffer's content. If not known, auto detection can be used.
  255. \return Returns true if compression information could be extracted from the the grab buffer or false otherwise.
  256. \error
  257. Throws an exception if the input parameters are invalid.
  258. \threading
  259. This method is thread-safe.
  260. */
  261. static bool GetCompressionInfo( CompressionInfo_t& compressionInfo, const void* pGrabBuffer, size_t payloadSize, EEndianness endianness = Endianness_Auto );
  262. /*!
  263. \brief Gets compression information about a grab result.
  264. \param[out] compressionInfo Reference to the struct that will receive the compression information if the grab result contains such information.
  265. \param[in] grabResult Grab result that holds the compressed data.
  266. \param[in] endianness Endianness of the grab result content. If not known, auto detection can be used.
  267. \return Returns true if compression information could be extracted from the the grab result or false otherwise.
  268. \error
  269. Throws an exception if the input parameters are invalid.
  270. \threading
  271. This method is thread-safe.
  272. */
  273. static bool GetCompressionInfo( CompressionInfo_t& compressionInfo, const Pylon::GrabResult& grabResult, EEndianness endianness = Endianness_Auto );
  274. /*!
  275. \brief Gets compression information about a grab result.
  276. \param[out] compressionInfo Reference to the struct that will receive the compression information if the grab result contains such information.
  277. \param[in] grabResultPtr Pointer to grab result that holds the compressed data.
  278. \param[in] endianness Endianness of the grab result content. If not known, auto detection can be used.
  279. \return Returns true if compression information could be extracted from the the grab result or false otherwise.
  280. \error
  281. Throws an exception if the input parameters are invalid.
  282. \threading
  283. This method is thread-safe.
  284. */
  285. static bool GetCompressionInfo( CompressionInfo_t& compressionInfo, const Pylon::CGrabResultPtr grabResultPtr, EEndianness endianness = Endianness_Auto );
  286. /*!
  287. \brief Computes the hash for a given compression descriptor.
  288. \param[out] pHash Pointer to the buffer that will receive the compression descriptor hash or
  289. NULL if you only want to get the size of the buffer for buffer allocation.
  290. \param[in,out] pSizeHash On input, the variable specifies the size of the buffer (in bytes)
  291. for the compression descriptor hash (if pHash is not NULL).
  292. On output, the variable will receive the actual buffer size required for the current
  293. compression descriptor hash.
  294. This parameter must not be NULL.
  295. \param[in] pCompressionDescriptor Pointer to the compression descriptor. This parameter must not be NULL.
  296. \param[in] sizeCompressionDescriptor Size of the data (in bytes) of the compression descriptor.
  297. \error
  298. Throws an exception if the input parameters are invalid (e.g., if the size provided is not sufficient to hold
  299. the compression descriptor hash).
  300. \threading
  301. This method is thread-safe.
  302. */
  303. static void ComputeCompressionDescriptorHash( void* pHash, size_t* pSizeHash, const void* pCompressionDescriptor, size_t sizeCompressionDescriptor );
  304. /*!
  305. \brief Gets the hash of the currently set compression descriptor.
  306. This method requires that a compression descriptor has been set previously via the constructor or
  307. the SetCompressionDescriptor methods. You can determine this via the HasCompressionDescriptor method.
  308. \param[out] pHash Pointer to the buffer that will receive the compression descriptor hash or
  309. NULL if you only want to get the size of the buffer for buffer allocation.
  310. \param[in,out] pSizeHash On input, the variable specifies the size of the buffer (in bytes)
  311. for the compression descriptor hash (if pHash is not NULL).
  312. On output, the variable will receive the actual buffer size required for the current
  313. compression descriptor hash.
  314. This parameter must not be NULL.
  315. \error
  316. Throws an exception if the decompressor has no compression descriptor set or the input parameters are
  317. invalid (e.g., if the size provided is not sufficient to hold the compression descriptor hash).
  318. \threading
  319. This method is thread-safe.
  320. */
  321. void GetCompressionDescriptorHash( void* pHash, size_t* pSizeHash ) const;
  322. /*!
  323. \brief Gets the hash of the current compression descriptor from the camera's node map.
  324. This method requires image compression to be enabled in the camera. You can determine this via the
  325. GetCompressionMode method.
  326. \param[out] pHash Pointer to the buffer that will receive the compression descriptor hash or
  327. NULL if you only want to get the size of the buffer for buffer allocation.
  328. \param[in,out] pSizeHash On input, the variable specifies the size of the buffer (in bytes)
  329. for the compression descriptor hash (if pHash is not NULL).
  330. On output, the variable will receive the actual buffer size required for the current
  331. compression descriptor hash.
  332. This parameter must not be NULL.
  333. \param[in] nodeMap Node map of the camera to be used for retrieving the compression descriptor hash.
  334. \error
  335. Throws an exception if compression is not active in the camera (or unavailable) or the input parameters
  336. are invalid (e.g., if the size provided is not sufficient to hold the compression descriptor hash).
  337. \threading
  338. This method is thread-safe.
  339. */
  340. static void GetCompressionDescriptorHash( void* pHash, size_t* pSizeHash, GenApi::INodeMap& nodeMap );
  341. /*!
  342. \brief Gets the hash of the compression descriptor that is required for decompressing the grab buffer provided.
  343. \param[out] pHash Pointer to the buffer that will receive the compression descriptor hash or
  344. NULL if you only want to get the size of the buffer for buffer allocation.
  345. \param[in,out] pSizeHash On input, the variable specifies the size of the buffer (in bytes)
  346. for the compression descriptor hash (if pHash is not NULL).
  347. On output, the variable will receive the actual buffer size required for the current
  348. compression descriptor hash.
  349. This parameter must not be NULL.
  350. \param[in] pGrabBuffer Pointer to the grab buffer that holds the compressed data. This parameter must not be NULL.
  351. \param[in] payloadSize Payload size (in bytes) of the data received (must be less or equal to the size of the grab buffer).
  352. \param[in] endianness Endianness of the grab buffer's content. If not known, auto detection can be used.
  353. \error
  354. Throws an exception if the grab buffer does not contain compressed data, the data is corrupt, or the input
  355. parameters are invalid (e.g., if the size provided is not sufficient to hold the compression descriptor hash).
  356. \threading
  357. This method is thread-safe.
  358. */
  359. static void GetCompressionDescriptorHash( void* pHash, size_t* pSizeHash, const void* pGrabBuffer, size_t payloadSize, EEndianness endianness = Endianness_Auto );
  360. /*!
  361. \brief Gets the hash of the compression descriptor that is required for decompressing the grab result provided.
  362. \param[out] pHash Pointer to the buffer that will receive the compression descriptor hash or
  363. NULL if you only want to get the size of the buffer for buffer allocation.
  364. \param[in,out] pSizeHash On input, the variable specifies the size of the buffer (in bytes)
  365. for the compression descriptor hash (if pHash is not NULL).
  366. On output, the variable will receive the actual buffer size required for the current
  367. compression descriptor hash.
  368. This parameter must not be NULL.
  369. \param[in] grabResult Grab result that holds the compressed data.
  370. \param[in] endianness Endianness of the grab result content. If not known, auto detection can be used.
  371. \error
  372. Throws an exception if the grab result does not contain compressed data, the data is corrupt, or the input
  373. parameters are invalid (e.g., if the size provided is not sufficient to hold the compression descriptor hash).
  374. \threading
  375. This method is thread-safe.
  376. */
  377. static void GetCompressionDescriptorHash( void* pHash, size_t* pSizeHash, const Pylon::GrabResult& grabResult, EEndianness endianness = Endianness_Auto );
  378. /*!
  379. \brief Gets the hash of the compression descriptor that is required for decompressing the grab result provided.
  380. \param[out] pHash Pointer to the buffer that will receive the compression descriptor hash or
  381. NULL if you only want to get the size of the buffer for buffer allocation.
  382. \param[in,out] pSizeHash On input, the variable specifies the size of the buffer (in bytes)
  383. for the compression descriptor hash (if pHash is not NULL).
  384. On output, the variable will receive the actual buffer size required for the current
  385. compression descriptor hash.
  386. This parameter must not be NULL.
  387. \param[in] grabResultPtr Pointer to grab result that holds the compressed data.
  388. \param[in] endianness Endianness of the grab result content. If not known, auto detection can be used.
  389. \error
  390. Throws an exception if the grab result does not contain compressed data, the data is corrupt, or the input
  391. parameters are invalid (e.g., if the size provided is not sufficient to hold the compression descriptor hash).
  392. \threading
  393. This method is thread-safe.
  394. */
  395. static void GetCompressionDescriptorHash( void* pHash, size_t* pSizeHash, const Pylon::CGrabResultPtr grabResultPtr, EEndianness endianness = Endianness_Auto );
  396. /*!
  397. \brief Gets size (in bytes) required for allocating buffers for decompressing the images during streaming.
  398. This method requires image compression to be enabled in the camera. You can determine this via the
  399. GetCompressionMode method.
  400. \param[in] nodeMap Node map of the camera to be used for retrieving the image size required for decompression.
  401. \return Returns the buffer size (in bytes) required for image decompression.
  402. \error
  403. Throws an exception if an error is encountered while determining the image size required for decompression.
  404. \threading
  405. This method is thread-safe.
  406. */
  407. static size_t GetImageSizeForDecompression( GenApi::INodeMap& nodeMap );
  408. /*!
  409. \brief Decompresses the image of the grab buffer provided.
  410. This method requires that a compression descriptor has been set previously via the constructor or
  411. the SetCompressionDescriptor methods. You can determine this via the HasCompressionDescriptor method.
  412. The grab buffer provided must contain a compressed image that has been received without errors.
  413. \param[out] pOutputBuffer Pointer to the buffer that will receive the decompressed image. This parameter must
  414. not be NULL.
  415. \param[in,out] pSizeOutputBuffer On input, the variable specifies the size of the buffer (in bytes)
  416. for the decompressed image (must be larger or equal to the value in the decompressedImageSize
  417. field in the CompressionInfo_t struct received via the GetCompressionInfo methods;
  418. alternatively, the GetImageSizeForDecompression method can be used to get the image
  419. size required for decompression).
  420. On output, the variable will receive the actual buffer size required for the decompressed image.
  421. This parameter must not be NULL.
  422. \param[in] pGrabBuffer Pointer to the grab buffer that holds the compressed data. This parameter must not be NULL.
  423. \param[in] payloadSize Payload size (in bytes) of the data received (must be less or equal to the size of the grab buffer).
  424. \return Returns the struct with the compression information of the compressed image.
  425. \error
  426. Throws an exception if the grab buffer does not contain compressed data, the data is corrupt, the image cannot
  427. be decompressed, or the input parameters are invalid (e.g., if the size provided is not sufficient to hold the
  428. decompressed image).
  429. \threading
  430. This method is thread-safe.
  431. */
  432. CompressionInfo_t DecompressImage( void* pOutputBuffer, size_t* pSizeOutputBuffer, const void* pGrabBuffer, size_t payloadSize ) const;
  433. /*!
  434. \brief Decompresses the image of the grab result provided.
  435. This method requires that a compression descriptor has been set previously via the constructor or
  436. the SetCompressionDescriptor methods. You can determine this via the HasCompressionDescriptor method.
  437. The grab result provided must contain a compressed image that has been received without errors.
  438. \param[out] pOutputBuffer Pointer to the buffer that will receive the decompressed image. This parameter must
  439. not be NULL.
  440. \param[in,out] pSizeOutputBuffer On input, the variable specifies the size of the buffer (in bytes)
  441. for the decompressed image (must be larger or equal to the value in the decompressedImageSize
  442. field in the CompressionInfo_t struct received via the GetCompressionInfo
  443. methods; alternatively, the GetImageSizeForDecompression method can be used to get the image
  444. size required for decompression).
  445. On output, the variable will receive the actual buffer size required for the decompressed image.
  446. This parameter must not be NULL.
  447. \param[in] grabResult Grab result that holds the compressed data.
  448. \return Returns the struct with the compression information about the compressed image.
  449. \error
  450. Throws an exception if the grab result does not contain compressed data, the data is corrupt, the image cannot
  451. be decompressed or the input parameters are invalid (e.g., if the size provided is not sufficient to hold the
  452. decompressed image).
  453. \threading
  454. This method is thread-safe.
  455. */
  456. CompressionInfo_t DecompressImage( void* pOutputBuffer, size_t* pSizeOutputBuffer, const Pylon::GrabResult& grabResult ) const;
  457. /*!
  458. \brief Decompresses the image of the grab result provided.
  459. This method requires that a compression descriptor has been set previously via the constructor or
  460. the SetCompressionDescriptor methods. You can determine this via the HasCompressionDescriptor method.
  461. The grab result provided must contain a compressed image that has been received without errors.
  462. \param[out] pOutputBuffer Pointer to the buffer that will receive the decompressed image. This parameter must
  463. not be NULL.
  464. \param[in,out] pSizeOutputBuffer On input, the variable specifies the size of the buffer (in bytes)
  465. for the decompressed image (must be larger or equal to the value in the decompressedImageSize
  466. field in the CompressionInfo_t struct received via the GetCompressionInfo methods;
  467. alternatively, the GetImageSizeForDecompression method can be used to get the image
  468. size required for decompression).
  469. On output, the variable will receive the actual buffer size required for the decompressed image.
  470. This parameter must not be NULL.
  471. \param[in] grabResultPtr Pointer to grab result that holds the compressed data.
  472. \return Returns the struct with the compression information about the compressed image.
  473. \error
  474. Throws an exception if the grab result does not contain compressed data, the data is corrupt, the image cannot
  475. be decompressed or the input parameters are invalid (e.g., if the size provided is not sufficient to hold the
  476. decompressed image).
  477. \threading
  478. This method is thread-safe.
  479. */
  480. CompressionInfo_t DecompressImage( void* pOutputBuffer, size_t* pSizeOutputBuffer, const Pylon::CGrabResultPtr grabResultPtr ) const;
  481. /*!
  482. \brief Decompresses the image of the grab buffer provided.
  483. This method requires that a compression descriptor has been set previously via the constructor or
  484. the SetCompressionDescriptor methods. You can determine this via the HasCompressionDescriptor method.
  485. The grab buffer provided must contain a compressed image that has been received without errors.
  486. \param[out] destinationImage Image object (e.g., instance of CPylonImage) that will be filled with the decompressed
  487. image (will be resized if required).
  488. \param[in] pGrabBuffer Pointer to the grab buffer that holds the compressed data. This parameter must not be NULL.
  489. \param[in] payloadSize Payload size (in bytes) of the data received (must be less or equal to the size of the grab buffer).
  490. \return Returns the struct with the compression information about the compressed image.
  491. \error
  492. Throws an exception if the grab buffer does not contain compressed data, the data is corrupt, the image cannot
  493. be decompressed or the input parameters are invalid.
  494. \threading
  495. This method is thread-safe.
  496. */
  497. CompressionInfo_t DecompressImage( IReusableImage& destinationImage, const void* pGrabBuffer, size_t payloadSize ) const;
  498. /*!
  499. \brief Decompresses the image of the grab result provided.
  500. This method requires that a compression descriptor has been set previously via the constructor or
  501. the SetCompressionDescriptor methods. You can determine this via the HasCompressionDescriptor method.
  502. The grab result provided must contain a compressed image that has been received without errors.
  503. \param[out] destinationImage Image object (e.g., instance of CPylonImage) that will be filled with the decompressed
  504. image (will be resized if required).
  505. \param[in] grabResult Grab result that holds the compressed data.
  506. \return Returns the struct with the compression information about the compressed image.
  507. \error
  508. Throws an exception if the grab result does not contain compressed data, the data is corrupt, the image cannot be
  509. decompressed, or the input parameters are invalid.
  510. \threading
  511. This method is thread-safe.
  512. */
  513. CompressionInfo_t DecompressImage( IReusableImage& destinationImage, const Pylon::GrabResult& grabResult ) const;
  514. /*!
  515. \brief Decompresses the image of the grab result provided.
  516. This method requires that a compression descriptor has been set previously via the constructor or
  517. the SetCompressionDescriptor methods. You can determine this via the HasCompressionDescriptor method.
  518. The grab result provided must contain a compressed image that has been received without errors.
  519. \param[out] destinationImage Image object (e.g., instance of CPylonImage) that will be filled with the decompressed
  520. image (will be resized if required).
  521. \param[in] grabResultPtr Pointer to grab result that holds the compressed data.
  522. \return Returns the struct with the compression information about the compressed image.
  523. \error
  524. Throws an exception if the grab result does not contain compressed data, the data is corrupt, the image cannot be
  525. decompressed, or the input parameters are invalid.
  526. \threading
  527. This method is thread-safe.
  528. */
  529. CompressionInfo_t DecompressImage( IReusableImage& destinationImage, const Pylon::CGrabResultPtr grabResultPtr ) const;
  530. /*!
  531. \brief Copies the decompressor.
  532. \param[in] imageDecompressor The source decompressor.
  533. \return Returns a reference to the destination decompressor.
  534. \error
  535. Does not throw C++ exceptions.
  536. \threading
  537. This method is thread-safe.
  538. */
  539. CImageDecompressor& operator = ( const CImageDecompressor& imageDecompressor );
  540. /*!
  541. \brief Compares this instance with another decompressor.
  542. \param[in] imageDecompressor The decompressor on the right-hand side of the comparison.
  543. \return True if both decompressors are equal or false otherwise.
  544. \error
  545. Does not throw C++ exceptions.
  546. \threading
  547. This method is thread-safe.
  548. */
  549. bool operator == ( const CImageDecompressor& imageDecompressor );
  550. private:
  551. struct Impl_t;
  552. Impl_t* m_pImpl;
  553. };
  554. #ifdef _MSC_VER
  555. # pragma pack(pop)
  556. #endif /* _MSC_VER */
  557. } //namespace Pylon
  558. #endif // INCLUDED_IMAGEDECOMPRESSOR_H_C5305647