Frame.cpp
Go to the documentation of this file.
1 /*=============================================================================
2  Copyright (C) 2012 Allied Vision Technologies. All Rights Reserved.
3 
4  Redistribution of this file, in original or modified form, without
5  prior written consent of Allied Vision Technologies is prohibited.
6 
7 -------------------------------------------------------------------------------
8 
9  File: Frame.cpp
10 
11  Description: Implementation of class AVT::VmbAPI::Frame.
12 
13 -------------------------------------------------------------------------------
14 
15  THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
16  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF TITLE,
17  NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18  DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
19  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
22  AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
23  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
24  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 
26 =============================================================================*/
27 
28 #include <VimbaCPP/Include/Frame.h>
29 
35 
36 namespace AVT {
37 namespace VmbAPI {
38 
40 {
41  // No default ctor
42 }
43 
45 {
46  // No copy ctor
47 }
48 
50 {
51  // No assignment operator
52  return *this;
53 }
54 
55 Frame::Frame( VmbInt64_t nBufferSize )
56  : m_pImpl( new Impl() )
57 {
59  m_pImpl->m_bAlreadyQueued = false;
60  m_pImpl->m_bIsUserBuffer = false;
62  m_pImpl->Init();
63  m_pImpl->m_pBuffer = new VmbUchar_t[ (VmbUint32_t)nBufferSize ];
64  m_pImpl->m_frame.bufferSize = (VmbUint32_t)nBufferSize;
66 }
67 
68 Frame::Frame( VmbUchar_t *pBuffer, VmbInt64_t nBufferSize )
69  : m_pImpl( new Impl() )
70 {
72  m_pImpl->m_bAlreadyQueued = false;
73  m_pImpl->m_bIsUserBuffer = true;
74  m_pImpl->m_pBuffer = NULL;
76  m_pImpl->Init();
77  if ( NULL != pBuffer )
78  {
79  m_pImpl->m_pBuffer = pBuffer;
80  m_pImpl->m_frame.bufferSize = (VmbUint32_t)nBufferSize;
82  }
83  else
84  {
85  // Do some logging
86  LOG_FREE_TEXT( "No valid buffer passed when constructing frame." )
87  }
88 }
89 
91 {
92  m_frame.ancillarySize = 0;
93  m_frame.buffer = NULL;
94  m_frame.bufferSize = 0;
95  for ( int i=0; i<4; ++i)
96  {
97  m_frame.context[i] = NULL;
98  }
99  m_frame.frameID = 0;
100  m_frame.height = 0;
101  m_frame.imageSize = 0;
102  m_frame.offsetX = 0;
103  m_frame.offsetY = 0;
104  m_frame.pixelFormat = 0;
105  m_frame.receiveFlags = VmbFrameFlagsNone;
106  m_frame.receiveStatus = VmbFrameStatusInvalid;
107  m_frame.timestamp = 0;
108  m_frame.width = 0;
109 }
110 
112 {
114  if ( false == m_pImpl->m_bIsUserBuffer
115  && NULL != m_pImpl->m_pBuffer )
116  {
117  delete [] m_pImpl->m_pBuffer;
118  }
119 
120  delete m_pImpl;
121 }
122 
123 VmbErrorType Frame::RegisterObserver( const IFrameObserverPtr &rObserver )
124 {
125  if ( SP_ISNULL( rObserver ))
126  {
127  return VmbErrorBadParameter;
128  }
129 
130  // Begin exclusive write lock observer
132  {
133  m_pImpl->m_pObserver = rObserver;
134 
135  // End write lock observer
137 
138  return VmbErrorSuccess;
139  }
140  else
141  {
142  LOG_FREE_TEXT( "Could not lock frame observer.")
143  return VmbErrorResources;
144  }
145 }
146 
148 {
150 
151  // Begin exclusive write lock observer
153  {
154  if ( SP_ISNULL( m_pImpl->m_pObserver ))
155  {
156  res = VmbErrorNotFound;
157  }
158  else
159  {
161  }
162 
163  // End exclusive write lock observer
165  }
166  else
167  {
168  LOG_FREE_TEXT( "Could not lock frame observer.")
169  res = VmbErrorResources;
170  }
171 
172  return res;
173 }
174 
175 bool Frame::GetObserver( IFrameObserverPtr &rObserver ) const
176 {
177  if ( SP_ISNULL( m_pImpl->m_pObserver ))
178  {
179  return false;
180  }
181 
182  // Begin read lock observer
184  {
185  rObserver = m_pImpl->m_pObserver;
186  // End read lock observer
188  return true;
189  }
190  else
191  {
192  LOG_FREE_TEXT( "Could not lock frame observer.")
193  }
194 
195  return false;
196 }
197 
199 {
200  if ( m_pImpl->m_frame.ancillarySize == 0 )
201  {
202  return VmbErrorNotFound;
203  }
204 
205  SP_SET( rAncillaryData, new AncillaryData( &m_pImpl->m_frame ));
206 
207  return VmbErrorSuccess;
208 }
209 
211 {
212  if ( m_pImpl->m_frame.ancillarySize == 0 )
213  {
214  return VmbErrorNotFound;
215  }
216 
217  SP_SET( rAncillaryData, new AncillaryData( &m_pImpl->m_frame ));
218 
219  return VmbErrorSuccess;
220 }
221 
223 {
224  rpBuffer = m_pImpl->m_pBuffer;
225 
226  return VmbErrorSuccess;
227 }
228 
229 VmbErrorType Frame::GetBuffer( const VmbUchar_t* &rpBuffer ) const
230 {
231  rpBuffer = m_pImpl->m_pBuffer;
232 
233  return VmbErrorSuccess;
234 }
235 
237 {
238  // HINT: On Allied Vision cameras image data always is at the beginning of the buffer
239  rpBuffer = m_pImpl->m_pBuffer;
240 
241  return VmbErrorSuccess;
242 }
243 
244 VmbErrorType Frame::GetImage( const VmbUchar_t* &rpBuffer ) const
245 {
246  // HINT: On Allied Vision cameras image data always is at the beginning of the buffer
247  rpBuffer = m_pImpl->m_pBuffer;
248 
249  return VmbErrorSuccess;
250 }
251 
253 {
255 
256  return VmbErrorSuccess;
257 }
258 
260 {
261  rnImageSize = m_pImpl->m_frame.imageSize;
262 
263  return VmbErrorSuccess;
264 }
265 
267 {
268  rnAncillarySize = m_pImpl->m_frame.ancillarySize;
269 
270  return VmbErrorSuccess;
271 }
272 
274 {
275  rnBufferSize =m_pImpl-> m_frame.bufferSize;
276 
277  return VmbErrorSuccess;
278 }
279 
281 {
283 
284  return VmbErrorSuccess;
285 }
286 
288 {
289  rnWidth = m_pImpl->m_frame.width;
290 
291  return VmbErrorSuccess;
292 }
293 
295 {
296  rnHeight = m_pImpl->m_frame.height;
297 
298  return VmbErrorSuccess;
299 }
300 
302 {
303  rnOffsetX = m_pImpl->m_frame.offsetX;
304 
305  return VmbErrorSuccess;
306 }
307 
309 {
310  rnOffsetY = m_pImpl->m_frame.offsetY;
311 
312  return VmbErrorSuccess;
313 }
314 
316 {
317  rnFrameID = m_pImpl->m_frame.frameID;
318 
319  return VmbErrorSuccess;
320 }
321 
323 {
324  rnTimestamp = m_pImpl->m_frame.timestamp;
325 
326  return VmbErrorSuccess;
327 }
328 
329 }} // namespace AVT::VmbAPI
IMEXPORT VmbErrorType GetAncillaryData(AncillaryDataPtr &pAncillaryData)
Definition: Frame.cpp:198
VmbUint32_t bufferSize
Definition: VimbaC.h:276
IMEXPORT VmbErrorType RegisterObserver(const IFrameObserverPtr &pObserver)
Definition: Frame.cpp:123
ConditionHelper m_observerConditionHelper
Definition: FrameImpl.h:45
bool EnterWriteLock(BasicLockable &rLockable, bool bExclusive=false)
#define SP_ISNULL(sp)
IFrameObserverPtr m_pObserver
Definition: FrameImpl.h:43
IMEXPORT VmbErrorType GetOffsetY(VmbUint32_t &offsetY) const
Definition: Frame.cpp:308
VmbUint32_t offsetX
Definition: VimbaC.h:291
#define SP_RESET(sp)
VmbPixelFormatType
long long VmbInt64_t
IMEXPORT ~Frame()
Definition: Frame.cpp:111
NetPointer< AncillaryData, AVT::VmbAPINET::AncillaryData > AncillaryDataPtr
VmbUint32_t height
Definition: VimbaC.h:290
VmbUint64_t frameID
Definition: VimbaC.h:294
bool GetObserver(IFrameObserverPtr &observer) const
Definition: Frame.cpp:175
VmbUint32_t ancillarySize
Definition: VimbaC.h:285
void ExitWriteLock(BasicLockable &rLockable)
VmbUchar_t * m_pBuffer
Definition: FrameImpl.h:38
IMEXPORT VmbErrorType GetBuffer(VmbUchar_t *&pBuffer)
Definition: Frame.cpp:222
IMEXPORT VmbErrorType GetFrameID(VmbUint64_t &frameID) const
Definition: Frame.cpp:315
VmbErrorType
VmbUint32_t imageSize
Definition: VimbaC.h:284
IMEXPORT VmbErrorType GetHeight(VmbUint32_t &height) const
Definition: Frame.cpp:294
IMEXPORT VmbErrorType GetImageSize(VmbUint32_t &imageSize) const
Definition: Frame.cpp:259
#define LOG_FREE_TEXT(txt)
Definition: LoggerDefines.h:57
Impl * m_pImpl
Definition: Frame.h:324
unsigned char VmbUchar_t
IMEXPORT VmbErrorType GetReceiveStatus(VmbFrameStatusType &status) const
Definition: Frame.cpp:252
unsigned long long VmbUint64_t
VmbFrameStatus_t receiveStatus
Definition: VimbaC.h:281
VmbUint64_t timestamp
Definition: VimbaC.h:295
IMEXPORT VmbErrorType UnregisterObserver()
Definition: Frame.cpp:147
IMEXPORT VmbErrorType GetBufferSize(VmbUint32_t &bufferSize) const
Definition: Frame.cpp:273
#define SP_SET(sp, rawPtr)
void ExitReadLock(BasicLockable &rLockable)
IMEXPORT VmbErrorType GetWidth(VmbUint32_t &width) const
Definition: Frame.cpp:287
VmbUint32_t width
Definition: VimbaC.h:289
unsigned int VmbUint32_t
bool EnterReadLock(BasicLockable &rLockable)
IMEXPORT VmbErrorType GetAncillarySize(VmbUint32_t &ancillarySize) const
Definition: Frame.cpp:266
Frame & operator=(const Frame &)
Definition: Frame.cpp:49
IMEXPORT VmbErrorType GetImage(VmbUchar_t *&pBuffer)
Definition: Frame.cpp:236
void * buffer
Definition: VimbaC.h:275
IMEXPORT VmbErrorType GetTimestamp(VmbUint64_t &timestamp) const
Definition: Frame.cpp:322
IMEXPORT VmbErrorType GetOffsetX(VmbUint32_t &offsetX) const
Definition: Frame.cpp:301
VmbPixelFormat_t pixelFormat
Definition: VimbaC.h:287
VmbUint32_t offsetY
Definition: VimbaC.h:292
NetPointer< AncillaryData, AVT::VmbAPINET::AncillaryData > ConstAncillaryDataPtr
IMEXPORT VmbErrorType GetPixelFormat(VmbPixelFormatType &pixelFormat) const
Definition: Frame.cpp:280
VmbFrameStatusType
Definition: VimbaC.h:246


avt_vimba_camera
Author(s): Miquel Massot , Allied Vision Technologies
autogenerated on Wed Jun 5 2019 22:22:40