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 
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
131  MutexGuard local_lock( m_pImpl->m_pObserverMutex );
132  m_pImpl->m_pObserver = rObserver;
133  return VmbErrorSuccess;
134 }
135 
137 {
139 
140  // Begin exclusive write lock observer
141  MutexGuard local_lock( m_pImpl->m_pObserverMutex );
142  if ( SP_ISNULL( m_pImpl->m_pObserver ))
143  {
144  res = VmbErrorNotFound;
145  }
146  else
147  {
149  }
150  return res;
151 }
152 
153 bool Frame::GetObserver( IFrameObserverPtr &rObserver ) const
154 {
155  MutexGuard local_lock( m_pImpl->m_pObserverMutex );
156  if ( SP_ISNULL( m_pImpl->m_pObserver ))
157  {
158  return false;
159  }
160  rObserver = m_pImpl->m_pObserver;
161  return true;
162 }
163 
164 VmbErrorType Frame::GetAncillaryData( AncillaryDataPtr &rAncillaryData )
165 {
166  if ( m_pImpl->m_frame.ancillarySize == 0 )
167  {
168  return VmbErrorNotFound;
169  }
170 
171  SP_SET( rAncillaryData, new AncillaryData( &m_pImpl->m_frame ));
172 
173  return VmbErrorSuccess;
174 }
175 
176 VmbErrorType Frame::GetAncillaryData( ConstAncillaryDataPtr &rAncillaryData ) const
177 {
178  if ( m_pImpl->m_frame.ancillarySize == 0 )
179  {
180  return VmbErrorNotFound;
181  }
182 
183  SP_SET( rAncillaryData, new AncillaryData( &m_pImpl->m_frame ));
184 
185  return VmbErrorSuccess;
186 }
187 
189 {
190  rpBuffer = m_pImpl->m_pBuffer;
191 
192  return VmbErrorSuccess;
193 }
194 
195 VmbErrorType Frame::GetBuffer( const VmbUchar_t* &rpBuffer ) const
196 {
197  rpBuffer = m_pImpl->m_pBuffer;
198 
199  return VmbErrorSuccess;
200 }
201 
203 {
204  // HINT: On Allied Vision cameras image data always is at the beginning of the buffer
205  rpBuffer = m_pImpl->m_pBuffer;
206 
207  return VmbErrorSuccess;
208 }
209 
210 VmbErrorType Frame::GetImage( const VmbUchar_t* &rpBuffer ) const
211 {
212  // HINT: On Allied Vision cameras image data always is at the beginning of the buffer
213  rpBuffer = m_pImpl->m_pBuffer;
214 
215  return VmbErrorSuccess;
216 }
217 
219 {
221 
222  return VmbErrorSuccess;
223 }
224 
226 {
227  rnImageSize = m_pImpl->m_frame.imageSize;
228 
229  return VmbErrorSuccess;
230 }
231 
233 {
234  rnAncillarySize = m_pImpl->m_frame.ancillarySize;
235 
236  return VmbErrorSuccess;
237 }
238 
240 {
241  rnBufferSize =m_pImpl-> m_frame.bufferSize;
242 
243  return VmbErrorSuccess;
244 }
245 
247 {
249 
250  return VmbErrorSuccess;
251 }
252 
254 {
255  rnWidth = m_pImpl->m_frame.width;
256 
257  return VmbErrorSuccess;
258 }
259 
261 {
262  rnHeight = m_pImpl->m_frame.height;
263 
264  return VmbErrorSuccess;
265 }
266 
268 {
269  rnOffsetX = m_pImpl->m_frame.offsetX;
270 
271  return VmbErrorSuccess;
272 }
273 
275 {
276  rnOffsetY = m_pImpl->m_frame.offsetY;
277 
278  return VmbErrorSuccess;
279 }
280 
282 {
283  rnFrameID = m_pImpl->m_frame.frameID;
284 
285  return VmbErrorSuccess;
286 }
287 
289 {
290  rnTimestamp = m_pImpl->m_frame.timestamp;
291 
292  return VmbErrorSuccess;
293 }
294 
295 }} // namespace AVT::VmbAPI
IMEXPORT VmbErrorType GetAncillaryData(AncillaryDataPtr &pAncillaryData)
Definition: Frame.cpp:164
VmbUint32_t bufferSize
Definition: VimbaC.h:272
IMEXPORT VmbErrorType RegisterObserver(const IFrameObserverPtr &pObserver)
Definition: Frame.cpp:123
IMEXPORT VmbErrorType GetOffsetX(VmbUint32_t &offsetX) const
Definition: Frame.cpp:267
IMEXPORT VmbErrorType GetAncillarySize(VmbUint32_t &ancillarySize) const
Definition: Frame.cpp:232
#define SP_ISNULL(sp)
IFrameObserverPtr m_pObserver
Definition: FrameImpl.h:43
IMEXPORT VmbErrorType GetReceiveStatus(VmbFrameStatusType &status) const
Definition: Frame.cpp:218
VmbUint32_t offsetX
Definition: VimbaC.h:287
#define SP_RESET(sp)
VmbPixelFormatType
long long VmbInt64_t
IMEXPORT VmbErrorType GetFrameID(VmbUint64_t &frameID) const
Definition: Frame.cpp:281
IMEXPORT VmbErrorType GetTimestamp(VmbUint64_t &timestamp) const
Definition: Frame.cpp:288
IMEXPORT ~Frame()
Definition: Frame.cpp:111
VmbUint32_t height
Definition: VimbaC.h:286
VmbUint64_t frameID
Definition: VimbaC.h:290
VmbUint32_t ancillarySize
Definition: VimbaC.h:281
VmbUchar_t * m_pBuffer
Definition: FrameImpl.h:38
IMEXPORT VmbErrorType GetBuffer(VmbUchar_t *&pBuffer)
Definition: Frame.cpp:188
IMEXPORT VmbErrorType GetImageSize(VmbUint32_t &imageSize) const
Definition: Frame.cpp:225
VmbErrorType
VmbUint32_t imageSize
Definition: VimbaC.h:280
#define LOG_FREE_TEXT(txt)
Definition: LoggerDefines.h:56
Impl * m_pImpl
Definition: Frame.h:326
unsigned char VmbUchar_t
IMEXPORT VmbErrorType GetWidth(VmbUint32_t &width) const
Definition: Frame.cpp:253
unsigned long long VmbUint64_t
VmbFrameStatus_t receiveStatus
Definition: VimbaC.h:277
VmbUint64_t timestamp
Definition: VimbaC.h:291
IMEXPORT VmbErrorType UnregisterObserver()
Definition: Frame.cpp:136
IMEXPORT VmbErrorType GetPixelFormat(VmbPixelFormatType &pixelFormat) const
Definition: Frame.cpp:246
bool GetObserver(IFrameObserverPtr &observer) const
Definition: Frame.cpp:153
#define SP_SET(sp, rawPtr)
VmbUint32_t width
Definition: VimbaC.h:285
unsigned int VmbUint32_t
IMEXPORT VmbErrorType GetBufferSize(VmbUint32_t &bufferSize) const
Definition: Frame.cpp:239
Frame & operator=(const Frame &)
Definition: Frame.cpp:49
IMEXPORT VmbErrorType GetImage(VmbUchar_t *&pBuffer)
Definition: Frame.cpp:202
void * buffer
Definition: VimbaC.h:271
IMEXPORT VmbErrorType GetHeight(VmbUint32_t &height) const
Definition: Frame.cpp:260
VmbPixelFormat_t pixelFormat
Definition: VimbaC.h:283
VmbUint32_t offsetY
Definition: VimbaC.h:288
VmbFrameStatusType
Definition: VimbaC.h:243
IMEXPORT VmbErrorType GetOffsetY(VmbUint32_t &offsetY) const
Definition: Frame.cpp:274


avt_vimba_camera
Author(s): Allied Vision Technologies, Miquel Massot
autogenerated on Fri Jun 2 2023 02:21:10