Frame.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  1. /*=============================================================================
  2. Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
  3. Redistribution of this file, in original or modified form, without
  4. prior written consent of Allied Vision Technologies is prohibited.
  5. -------------------------------------------------------------------------------
  6. File: Frame.h
  7. Description: Definition of class AVT::VmbAPI::Frame.
  8. -------------------------------------------------------------------------------
  9. THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
  10. WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF TITLE,
  11. NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  12. DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
  13. INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  14. (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  15. LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
  16. AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
  17. TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  18. OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  19. =============================================================================*/
  20. #ifndef AVT_VMBAPI_FRAME_H
  21. #define AVT_VMBAPI_FRAME_H
  22. #include <VimbaC/Include/VimbaC.h>
  23. #include <VimbaCPP/Include/VimbaCPPCommon.h>
  24. #include <VimbaCPP/Include/SharedPointerDefines.h>
  25. #include <VimbaCPP/Include/IFrameObserver.h>
  26. #include <VimbaCPP/Include/AncillaryData.h>
  27. #include <vector>
  28. namespace AVT {
  29. namespace VmbAPI {
  30. class Camera; // forward declaration of camera class for befriending
  31. class Frame
  32. {
  33. friend class Camera;
  34. public:
  35. //
  36. // Method: Frame constructor
  37. //
  38. // Purpose: Creates an instance of class Frame of a certain size
  39. //
  40. // Parameters: [in ] VmbInt64_t bufferSize The size of the underlying buffer
  41. // Parameters: [in ] FrameAllocationMode allocationMode Indicates if announce frame or alloc and announce frame is used
  42. //
  43. IMEXPORT explicit Frame( VmbInt64_t bufferSize, FrameAllocationMode allocationMode = FrameAllocation_AnnounceFrame );
  44. //
  45. // Method: Frame constructor
  46. //
  47. // Purpose: Creates an instance of class Frame with the given user buffer of the given size
  48. //
  49. // Parameters: [in ] VmbUchar_t* pBuffer A pointer to an allocated buffer
  50. // Parameters: [in ] VmbInt64_t bufferSize The size of the underlying buffer
  51. //
  52. IMEXPORT Frame( VmbUchar_t *pBuffer, VmbInt64_t bufferSize );
  53. //
  54. // Method: Frame destructor
  55. //
  56. // Purpose: Destroys an instance of class Frame
  57. //
  58. IMEXPORT ~Frame();
  59. //
  60. // Method: RegisterObserver()
  61. //
  62. // Purpose: Registers an observer that will be called whenever a new frame arrives
  63. //
  64. // Parameters: [in ] const IFrameObserverPtr& pObserver An object that implements the IObserver interface
  65. //
  66. // Returns:
  67. //
  68. // - VmbErrorSuccess: If no error
  69. // - VmbErrorBadParameter: "pObserver" is NULL.
  70. // - VmbErrorResources: The observer was in use
  71. //
  72. // Details: As new frames arrive, the observer's FrameReceived method will be called.
  73. // Only one observer can be registered.
  74. //
  75. IMEXPORT VmbErrorType RegisterObserver( const IFrameObserverPtr &pObserver );
  76. //
  77. // Method: UnregisterObserver()
  78. //
  79. // Purpose: Unregisters the observer that was called whenever a new frame arrived
  80. //
  81. IMEXPORT VmbErrorType UnregisterObserver();
  82. //
  83. // Method: GetAncillaryData()
  84. //
  85. // Purpose: Returns the part of a frame that describes the chunk data as an object
  86. //
  87. // Parameters: [out] AncillaryDataPtr& pAncillaryData The wrapped chunk data
  88. //
  89. // Returns:
  90. //
  91. // - VmbErrorSuccess: If no error
  92. // - VmbErrorNotFound: No chunk data present
  93. //
  94. IMEXPORT VmbErrorType GetAncillaryData( AncillaryDataPtr &pAncillaryData );
  95. //
  96. // Method: GetAncillaryData()
  97. //
  98. // Purpose: Returns the part of a frame that describes the chunk data as an object
  99. //
  100. // Parameters: [out] ConstAncillaryDataPtr& pAncillaryData The wrapped chunk data
  101. //
  102. // Returns:
  103. //
  104. // - VmbErrorSuccess: If no error
  105. // - VmbErrorNotFound: No chunk data present
  106. //
  107. IMEXPORT VmbErrorType GetAncillaryData( ConstAncillaryDataPtr &pAncillaryData ) const;
  108. //
  109. // Method: GetBuffer()
  110. //
  111. // Purpose: Returns the complete buffer including image and chunk data
  112. //
  113. // Parameters: [out] VmbUchar_t* pBuffer A pointer to the buffer
  114. //
  115. // Returns:
  116. //
  117. // - VmbErrorSuccess: If no error
  118. //
  119. IMEXPORT VmbErrorType GetBuffer( VmbUchar_t* &pBuffer );
  120. //
  121. // Method: GetBuffer()
  122. //
  123. // Purpose: Returns the complete buffer including image and chunk data
  124. //
  125. // Parameters: [out] const VmbUchar_t* pBuffer A pointer to the buffer
  126. //
  127. // Returns:
  128. //
  129. // - VmbErrorSuccess: If no error
  130. //
  131. IMEXPORT VmbErrorType GetBuffer( const VmbUchar_t* &pBuffer ) const;
  132. //
  133. // Method: GetImage()
  134. //
  135. // Purpose: Returns only the image data
  136. //
  137. // Parameters: [out] VmbUchar_t* pBuffer A pointer to the buffer
  138. //
  139. // Returns:
  140. //
  141. // - VmbErrorSuccess: If no error
  142. //
  143. IMEXPORT VmbErrorType GetImage( VmbUchar_t* &pBuffer );
  144. //
  145. // Method: GetImage()
  146. //
  147. // Purpose: Returns only the image data
  148. //
  149. // Parameters: [out] const VmbUchar_t* pBuffer A pointer to the buffer
  150. //
  151. // Returns:
  152. //
  153. // - VmbErrorSuccess: If no error
  154. //
  155. IMEXPORT VmbErrorType GetImage( const VmbUchar_t* &pBuffer ) const;
  156. //
  157. // Method: GetReceiveStatus()
  158. //
  159. // Purpose: Returns the receive status of a frame
  160. //
  161. // Parameters: [out] VmbFrameStatusType& status The receive status
  162. //
  163. // Returns:
  164. //
  165. // - VmbErrorSuccess: If no error
  166. //
  167. IMEXPORT VmbErrorType GetReceiveStatus( VmbFrameStatusType &status ) const;
  168. //
  169. // Method: GetImageSize()
  170. //
  171. // Purpose: Returns the memory size of the image
  172. //
  173. // Parameters: [out] VmbUint32_t& imageSize The size in bytes
  174. //
  175. // Returns:
  176. //
  177. // - VmbErrorSuccess: If no error
  178. //
  179. IMEXPORT VmbErrorType GetImageSize( VmbUint32_t &imageSize ) const;
  180. //
  181. // Method: GetAncillarySize()
  182. //
  183. // Purpose: Returns memory size of the chunk data
  184. //
  185. // Parameters: [out] VmbUint32_t& ancillarySize The size in bytes
  186. //
  187. // Returns:
  188. //
  189. // - VmbErrorSuccess: If no error
  190. //
  191. IMEXPORT VmbErrorType GetAncillarySize( VmbUint32_t &ancillarySize ) const;
  192. //
  193. // Method: GetBufferSize()
  194. //
  195. // Purpose: Returns the memory size of the frame buffer holding
  196. // both the image data and the ancillary data
  197. //
  198. // Parameters: [out] VmbUint32_t& bufferSize The size in bytes
  199. //
  200. // Returns:
  201. //
  202. // - VmbErrorSuccess: If no error
  203. //
  204. IMEXPORT VmbErrorType GetBufferSize( VmbUint32_t &bufferSize ) const;
  205. //
  206. // Method: GetPixelFormat()
  207. //
  208. // Purpose: Returns the GenICam pixel format
  209. //
  210. // Parameters: [out] VmbPixelFormatType& pixelFormat The GenICam pixel format
  211. //
  212. // Returns:
  213. //
  214. // - VmbErrorSuccess: If no error
  215. //
  216. IMEXPORT VmbErrorType GetPixelFormat( VmbPixelFormatType &pixelFormat ) const;
  217. //
  218. // Method: GetWidth()
  219. //
  220. // Purpose: Returns the width of the image
  221. //
  222. // Parameters: [out] VmbUint32_t& width The width in pixels
  223. //
  224. // Returns:
  225. //
  226. // - VmbErrorSuccess: If no error
  227. //
  228. IMEXPORT VmbErrorType GetWidth( VmbUint32_t &width ) const;
  229. //
  230. // Method: GetHeight()
  231. //
  232. // Purpose: Returns the height of the image
  233. //
  234. // Parameters: [out] VmbUint32_t& height The height in pixels
  235. //
  236. // Returns:
  237. //
  238. // - VmbErrorSuccess: If no error
  239. //
  240. IMEXPORT VmbErrorType GetHeight( VmbUint32_t &height ) const;
  241. //
  242. // Method: GetOffsetX()
  243. //
  244. // Purpose: Returns the x offset of the image
  245. //
  246. // Parameters: [out] VmbUint32_t& offsetX The x offset in pixels
  247. //
  248. // Returns:
  249. //
  250. // - VmbErrorSuccess: If no error
  251. //
  252. IMEXPORT VmbErrorType GetOffsetX( VmbUint32_t &offsetX ) const;
  253. //
  254. // Method: GetOffsetY()
  255. //
  256. // Purpose: Returns the y offset of the image
  257. //
  258. // Parameters: [out] VmbUint32_t& offsetY The y offset in pixels
  259. //
  260. // Returns:
  261. //
  262. // - VmbErrorSuccess: If no error
  263. //
  264. IMEXPORT VmbErrorType GetOffsetY( VmbUint32_t &offsetY ) const;
  265. //
  266. // Method: GetFrameID()
  267. //
  268. // Purpose: Returns the frame ID
  269. //
  270. // Parameters: [out] VmbUint64_t& frameID The frame ID
  271. //
  272. // Returns:
  273. //
  274. // - VmbErrorSuccess: If no error
  275. //
  276. IMEXPORT VmbErrorType GetFrameID( VmbUint64_t &frameID ) const;
  277. //
  278. // Method: GetTimeStamp()
  279. //
  280. // Purpose: Returns the time stamp
  281. //
  282. // Parameters: [out] VmbUint64_t& timestamp The time stamp
  283. //
  284. // Returns:
  285. //
  286. // - VmbErrorSuccess: If no error
  287. //
  288. IMEXPORT VmbErrorType GetTimestamp( VmbUint64_t &timestamp ) const;
  289. bool GetObserver( IFrameObserverPtr &observer ) const;
  290. private:
  291. struct Impl;
  292. Impl *m_pImpl;
  293. // No default ctor
  294. Frame();
  295. // No copy ctor
  296. Frame( Frame& );
  297. // No assignment operator
  298. Frame& operator=( const Frame& );
  299. };
  300. typedef std::vector<FramePtr> FramePtrVector;
  301. }} // namespace AVT::VmbAPI
  302. #endif