PylonDataComponent.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353
  1. //-----------------------------------------------------------------------------
  2. // Basler pylon SDK
  3. // Copyright (c) 2020-2021 Basler AG
  4. // http://www.baslerweb.com
  5. // Author: DV, JS
  6. //-----------------------------------------------------------------------------
  7. /**
  8. \file
  9. \brief Contains a class to access one component of a multi-component grab result.
  10. */
  11. #ifndef INCLUDED_PYLONDATACOMPONENT_H
  12. #define INCLUDED_PYLONDATACOMPONENT_H
  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 <pylon/Image.h>
  21. namespace Pylon
  22. {
  23. // Forward declaration
  24. class CGrabResultPtr;
  25. class GrabResult;
  26. /**
  27. * \brief Lists the possible component types.
  28. *
  29. * Use this value to determine what kind of data is stored in a component.
  30. * You can call Pylon::CPylonDataComponent::GetComponentType().
  31. */
  32. enum EComponentType
  33. {
  34. ComponentType_Undefined = 0x00, //!< The component type is not known or hasn't been set.
  35. ComponentType_Intensity = 0x01, //!< Component contains intensity values
  36. ComponentType_Range = 0x04, //!< Component contains range values
  37. ComponentType_Confidence = 0x06 //!< Component contains confidence value
  38. };
  39. /**
  40. * \class CPylonDataComponent
  41. * \brief Provides methods for accessing a single component of CPylonDataContainer.
  42. *
  43. * \copydetails Pylon::CPylonDataContainer
  44. */
  45. class PYLONBASE_API CPylonDataComponent
  46. {
  47. public:
  48. /*!
  49. * \brief Creates an empty component.
  50. *
  51. * The default constructor will create an empty component.
  52. *
  53. * \error
  54. * Does not throw C++ exceptions.
  55. *
  56. * \threading
  57. * This class is not thread-safe.
  58. * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly.
  59. */
  60. CPylonDataComponent();
  61. /*!
  62. * \brief Creates a copy of an existing component.
  63. *
  64. * \param rhs Source component to copy.
  65. *
  66. * When creating a copy of a component, only the reference to the data in the container is copied.
  67. * The actual data pointed to by Pylon::CPylonDataComponent::GetData() will not be copied.
  68. *
  69. * \error
  70. * Does not throw C++ exceptions.
  71. *
  72. * \threading
  73. * This class is not thread-safe.
  74. * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly.
  75. */
  76. CPylonDataComponent( const CPylonDataComponent& rhs );
  77. /*!
  78. * \brief Destroys a pylon data component object.
  79. *
  80. * \error
  81. * Does not throw C++ exceptions.
  82. *
  83. * \threading
  84. * This class is not thread-safe.
  85. * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly.
  86. */
  87. ~CPylonDataComponent( );
  88. /*!
  89. * \brief Assigns the data of another component to this component by copying.
  90. *
  91. * \param rhs Source component to copy.
  92. *
  93. * When assigning a copy of a component, only the metadata is copied.
  94. * The actual data pointed to by Pylon::CPylonDataComponent::GetData() will not be copied.
  95. *
  96. * \post
  97. * <ul>
  98. * <li>Any container previously referenced is released.
  99. * <li>The container of the component passed is referenced.
  100. * <li>No container is referenced if the component passed is invalid.
  101. * </ul>
  102. *
  103. * \error
  104. * Does not throw C++ exceptions.
  105. *
  106. * \threading
  107. * This class is not thread-safe.
  108. * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly.
  109. */
  110. CPylonDataComponent& operator=( const CPylonDataComponent& rhs );
  111. /**
  112. * \brief Provides a Pylon::IImage interface to the component.
  113. *
  114. * This cast operator allows passing the component to image format converters,
  115. * save functions, or any other functions that require an IImage object.
  116. * The returned image is invalid if the component is invalid or cannot be converted to an image.
  117. *
  118. * \attention The returned reference is only valid as long as the component is not destroyed.
  119. *
  120. * \error
  121. * Does not throw C++ exceptions.
  122. *
  123. * \threading
  124. * This class is not thread-safe.
  125. * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly.
  126. */
  127. operator const Pylon::IImage& () const;
  128. /**
  129. * \brief Can be used to check whether the component is valid.
  130. *
  131. * \return Returns false if the component does not contain valid data or hasn't been initialized yet.
  132. *
  133. * \error
  134. * Does not throw C++ exceptions.
  135. *
  136. * \threading
  137. * This class is not thread-safe.
  138. * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly.
  139. */
  140. bool IsValid() const;
  141. /**
  142. * \brief Get the type of data this component contains.
  143. *
  144. * \return Returns the type of data in this component. See \c Pylon::EComponentType for values.
  145. *
  146. * Use this function to distinguish between different component types like
  147. * intensity values or range values. See Pylon::EComponentType for values.
  148. *
  149. * \error
  150. * Does not throw C++ exceptions.
  151. *
  152. * \threading
  153. * This class is not thread-safe.
  154. * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly.
  155. */
  156. EComponentType GetComponentType() const;
  157. /**
  158. * \brief Get the type of pixels this component contains.
  159. *
  160. * \return Returns an enumeration value describing the pixels in the component. See \c Pylon::EPixelType for values.
  161. * If the component does not contain valid data or contains a unknown pixel format, \c PixelType_Unknown is returned.
  162. *
  163. * Use this function to determine how to interpret the data returned by \c Pylon::CPylonDataComponent::GetData().
  164. * \note Not all components contain pixel data. Only components of type
  165. * ComponentType_Intensity, ComponentType_Range, and ComponentType_Confidence return a valid pixel type.
  166. *
  167. * \error
  168. * Does not throw C++ exceptions.
  169. *
  170. * \threading
  171. * This class is not thread-safe.
  172. * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly.
  173. */
  174. EPixelType GetPixelType() const;
  175. /**
  176. * \brief Get the current number of columns.
  177. *
  178. * \return Returns the current number of columns or 0 if the component is invalid.
  179. *
  180. * \error
  181. * Does not throw C++ exceptions.
  182. *
  183. * \threading
  184. * This class is not thread-safe.
  185. * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly.
  186. */
  187. uint32_t GetWidth() const;
  188. /**
  189. * \brief Get the current number of rows.
  190. *
  191. * \return Returns the current number of rows or 0 if the component is invalid.
  192. *
  193. * \error
  194. * Does not throw C++ exceptions.
  195. *
  196. * \threading
  197. * This class is not thread-safe.
  198. * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly.
  199. */
  200. uint32_t GetHeight() const;
  201. /**
  202. * \brief Get the starting column.
  203. *
  204. * \return Returns the starting column.
  205. *
  206. * \error
  207. * Does not throw C++ exceptions.
  208. *
  209. * \threading
  210. * This class is not thread-safe.
  211. * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly.
  212. */
  213. uint32_t GetOffsetX() const;
  214. /**
  215. * \brief Get the starting row.
  216. *
  217. * \return Returns the starting row.
  218. *
  219. * \error
  220. * Does not throw C++ exceptions.
  221. *
  222. * \threading
  223. * This class is not thread-safe.
  224. * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly.
  225. */
  226. uint32_t GetOffsetY() const;
  227. /**
  228. * \brief Get the number of extra bytes at the end of each row.
  229. *
  230. * \return Returns the number of extra bytes at the end of each row.
  231. *
  232. * \error
  233. * Does not throw C++ exceptions.
  234. *
  235. * \threading
  236. * This class is not thread-safe.
  237. * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly.
  238. */
  239. size_t GetPaddingX() const;
  240. /**
  241. * \brief Get the pointer to the data contained in the component.
  242. *
  243. * \return Returns a pointer to the data contained in the component.
  244. *
  245. * Use this pointer to access the data in this component.
  246. * The size in bytes of the buffer can be obtained by calling Pylon::CPylonDataComponent::GetDataSize().
  247. * Call Pylon::CPylonDataComponent::GetPixelFormat() and other methods to determine how to interpret the data.
  248. *
  249. * \error
  250. * Does not throw C++ exceptions.
  251. */
  252. const void* GetData() const;
  253. /**
  254. * \brief Get the size of the buffer returned by Pylon::CPylonDataComponent::GetData().
  255. *
  256. * \return Returns the size in bytes of the buffer returned by Pylon::CPylonDataComponent::GetData().
  257. *
  258. * \error
  259. * Does not throw C++ exceptions.
  260. *
  261. * \threading
  262. * This class is not thread-safe.
  263. * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly.
  264. */
  265. size_t GetDataSize() const;
  266. /**
  267. * \brief Get the camera-specific time the data was created on the camera.
  268. *
  269. * \return Returns the camera-specific time the data was created on the camera
  270. * or 0 if the time is not available.
  271. *
  272. * \note Timestamp generation is available only on some camera models.
  273. *
  274. * \error
  275. * Does not throw C++ exceptions.
  276. *
  277. * \threading
  278. * This class is not thread-safe.
  279. * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly.
  280. */
  281. uint64_t GetTimeStamp() const;
  282. /**
  283. * \brief Get the stride in bytes for the component.
  284. *
  285. * \param[out] strideBytes On successful return, the stride value can be read from this output parameter.
  286. *
  287. * \return Returns true if the stride could be computed successfully and is returned in the output parameter.
  288. * Returns false if the preconditions are not met or the component doesn't contain valid data.
  289. * If the function returns false, the value of strideBytes is undefined.
  290. *
  291. * This method uses \c Pylon::ComputeStride() to compute the component's stride value.
  292. * The stride describes the amount of bytes to advance from one row to the next.
  293. *
  294. * \pre
  295. * <ul>
  296. * <li> The component type must be Pylon::ComponentType_Intensity, Pylon::ComponentType_Range, or Pylon::ComponentType_Confidence.
  297. * <li> The preconditions of \c ComputeStride() must be met.
  298. * </ul>
  299. *
  300. * \error
  301. * Does not throw C++ exceptions.
  302. *
  303. * \threading
  304. * This class is not thread-safe.
  305. * If you access the same instance from multiple threads, you must make sure to synchronize the access accordingly.
  306. */
  307. bool GetStride( size_t& strideBytes ) const;
  308. protected:
  309. class CPylonDataComponentImpl;
  310. CPylonDataComponentImpl* m_pImpl;
  311. };
  312. } // namespace Pylon
  313. #endif // INCLUDED_PYLONDATACOMPONENT_H