Camera.hpp
Go to the documentation of this file.
1 /*=============================================================================
2  Copyright (C) 2012 - 2016 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: Camera.hpp
10 
11  Description: Inline wrapper functions for class AVT::VmbAPI::Camera.
12  (This include file is for internal use only.)
13 
14 -------------------------------------------------------------------------------
15 
16  THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
17  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF TITLE,
18  NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
20  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
23  AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
24  TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 
27 =============================================================================*/
28 
29 #ifndef AVT_VMBAPI_CAMERA_HPP
30 #define AVT_VMBAPI_CAMERA_HPP
31 
32 //
33 // Inline wrapper functions that allocate memory for STL objects in the application's context
34 // and to pass data across DLL boundaries using arrays
35 //
36 
37 // HINT: This information remains static throughout the object's lifetime
38 inline VmbErrorType Camera::GetID( std::string &rStrID ) const
39 {
40  VmbErrorType res;
41  VmbUint32_t nLength;
42 
43  res = GetID( NULL, nLength );
44  if ( VmbErrorSuccess == res )
45  {
46  if ( 0 != nLength )
47  {
48  try
49  {
50  std::vector<std::string::value_type>tmpID( nLength + 1,'\0');
51  res = GetID( &tmpID[0], nLength );
52  if( VmbErrorSuccess == res)
53  {
54  rStrID = &*tmpID.begin();
55  }
56  }
57  catch(...)
58  {
59  res = VmbErrorResources;
60  }
61  }
62  else
63  {
64  rStrID.clear();
65  }
66  }
67 
68  return res;
69 }
70 
71 // HINT: This information remains static throughout the object's lifetime
72 inline VmbErrorType Camera::GetName( std::string &rStrName ) const
73 {
74  VmbErrorType res;
75  VmbUint32_t nLength;
76 
77  res = GetName( NULL, nLength );
78  if ( VmbErrorSuccess == res )
79  {
80  if( 0 != nLength)
81  {
82  try
83  {
84  std::vector<std::string::value_type> tmpName( nLength + 1,'\0' );
85  res = GetName( &tmpName[0], nLength );
86  if( VmbErrorSuccess == res)
87  {
88  rStrName = &*tmpName.begin();
89  }
90  }
91  catch(...)
92  {
93  res = VmbErrorResources;
94  }
95  }
96  else
97  {
98  rStrName.clear();
99  }
100  }
101 
102  return res;
103 }
104 
105 // HINT: This information remains static throughout the object's lifetime
106 inline VmbErrorType Camera::GetModel( std::string &rStrModel ) const
107 {
108  VmbErrorType res;
109  VmbUint32_t nLength;
110 
111  res = GetModel( NULL, nLength );
112  if ( VmbErrorSuccess == res )
113  {
114  if( 0 != nLength)
115  {
116  try
117  {
118  std::vector<std::string::value_type> tmpModel( nLength + 1,'\0');
119  res = GetModel( &tmpModel[0], nLength );
120  if( VmbErrorSuccess == res )
121  {
122  rStrModel = &*tmpModel.begin();
123  }
124  }
125  catch(...)
126  {
127  res = VmbErrorResources;
128  }
129  }
130  else
131  {
132  rStrModel.clear();
133  }
134  }
135 
136  return res;
137 }
138 
139 // HINT: This information remains static throughout the object's lifetime
140 inline VmbErrorType Camera::GetSerialNumber( std::string &rStrSerial ) const
141 {
142  VmbErrorType res;
143  VmbUint32_t nLength;
144 
145  res = GetSerialNumber( NULL, nLength );
146  if ( VmbErrorSuccess == res )
147  {
148  if ( 0 != nLength )
149  {
150  try
151  {
152  std::vector<std::string::value_type> tmpSerial( nLength + 1,'\0');
153  res = GetSerialNumber( &tmpSerial[0], nLength );
154  if( VmbErrorSuccess == res )
155  {
156  rStrSerial = &*tmpSerial.begin();
157  }
158  }
159  catch(...)
160  {
161  res = VmbErrorResources;
162  }
163  }
164  else
165  {
166  rStrSerial.clear();
167  }
168  }
169 
170  return res;
171 }
172 
173 // HINT: This information remains static throughout the object's lifetime
174 inline VmbErrorType Camera::GetInterfaceID( std::string &rStrInterfaceID ) const
175 {
176  VmbErrorType res;
177  VmbUint32_t nLength;
178 
179  res = GetInterfaceID( NULL, nLength );
180  if ( VmbErrorSuccess == res )
181  {
182  if ( 0 != nLength )
183  {
184  try
185  {
186  std::vector<std::string::value_type> tmpID( nLength + 1,'\0');
187  res = GetInterfaceID( &tmpID[0], nLength );
188  if( VmbErrorSuccess == res )
189  {
190  rStrInterfaceID = &*tmpID.begin();
191  }
192  }
193  catch(...)
194  {
195  res = VmbErrorResources;
196  }
197  }
198  else
199  {
200  rStrInterfaceID.clear();
201  }
202  }
203 
204  return res;
205 }
206 
207 inline VmbErrorType Camera::AcquireMultipleImages( FramePtrVector &rFrames, VmbUint32_t nTimeout )
208 {
209  VmbErrorType res;
210  VmbUint32_t i;
211  res = AcquireMultipleImages( rFrames, nTimeout, i );
212  if ( rFrames.size() != i )
213  {
214  res = VmbErrorInternalFault;
215  }
216 
217  return res;
218 }
219 inline VmbErrorType Camera::AcquireMultipleImages( FramePtrVector &rFrames, VmbUint32_t nTimeout, VmbUint32_t &rNumFramesCompleted )
220 {
221  if ( true == rFrames.empty() )
222  {
223  return VmbErrorBadParameter;
224  }
225 
226  return AcquireMultipleImages( &rFrames[0], (VmbUint32_t)rFrames.size(), nTimeout, &rNumFramesCompleted );
227 }
228 
229 // HINT: Size of address determines how many registers to read. Size of data has to be large enough to hold the requested information
230 inline VmbErrorType Camera::ReadRegisters( const Uint64Vector &rAddresses, Uint64Vector &rBuffer ) const
231 {
232  VmbUint32_t i;
233  return ReadRegisters( rAddresses, rBuffer, i );
234 }
235 inline VmbErrorType Camera::ReadRegisters( const Uint64Vector &rAddresses, Uint64Vector &rBuffer, VmbUint32_t &rCompletedReads ) const
236 {
237  if ( true == rAddresses.empty()
238  || true == rBuffer.empty()
239  || rAddresses.size() > rBuffer.size() )
240  {
241  return VmbErrorBadParameter;
242  }
243  return ReadRegisters( &rAddresses[0], (VmbUint32_t)rAddresses.size(), &rBuffer[0], &rCompletedReads );
244 }
245 
246 // HINT: Size of address determines how many registers to write.
247 inline VmbErrorType Camera::WriteRegisters( const Uint64Vector &rAddresses, const Uint64Vector &rBuffer )
248 {
249  VmbUint32_t i;
250  return WriteRegisters( rAddresses, rBuffer, i );
251 }
252 inline VmbErrorType Camera::WriteRegisters( const Uint64Vector &rAddresses, const Uint64Vector &rBuffer, VmbUint32_t &rCompletedWrites )
253 {
254  if ( true == rAddresses.empty()
255  || true == rBuffer.empty()
256  || rAddresses.size() != rBuffer.size() )
257  {
258  return VmbErrorBadParameter;
259  }
260 
261  return WriteRegisters( &rAddresses[0], (VmbUint32_t)rAddresses.size(), &rBuffer[0], &rCompletedWrites );
262 }
263 
264 // HINT: Size of buffer determines how many bytes to read.
265 inline VmbErrorType Camera::ReadMemory( const VmbUint64_t &rAddress, UcharVector &rBuffer ) const
266 {
267  VmbUint32_t i;
268  return ReadMemory( rAddress, rBuffer, i );
269 }
270 inline VmbErrorType Camera::ReadMemory( const VmbUint64_t &rAddress, UcharVector &rBuffer, VmbUint32_t &rCompletedReads ) const
271 {
272  if ( true == rBuffer.empty() )
273  {
274  return VmbErrorBadParameter;
275  }
276 
277  return ReadMemory( rAddress, &rBuffer[0], (VmbUint32_t)rBuffer.size(), &rCompletedReads );
278 }
279 
280 // HINT: Size of buffer determines how many bytes to write.
281 inline VmbErrorType Camera::WriteMemory( const VmbUint64_t &rAddress, const UcharVector &rBuffer )
282 {
283  VmbUint32_t i;
284  return WriteMemory( rAddress, rBuffer, i );
285 }
286 inline VmbErrorType Camera::WriteMemory( const VmbUint64_t &rAddress, const UcharVector &rBuffer, VmbUint32_t &rCompletedWrites )
287 {
288  if ( true == rBuffer.empty() )
289  {
290  return VmbErrorBadParameter;
291  }
292 
293  return WriteMemory( rAddress, &rBuffer[0], (VmbUint32_t)rBuffer.size(), &rCompletedWrites );
294 }
295 
296 inline VmbErrorType Camera::SaveCameraSettings( std::string strFileName, VmbFeaturePersistSettings_t *pSettings ) const
297 {
299 
300 // parameter check
301  if( true == strFileName.empty() )
302  {
303  return VmbErrorBadParameter;
304  }
305 
306 // check internal settings struct variables
307  VmbBool_t useInternalStruct = true;
308  if( false == ((0 <= m_persistType) && (3 > m_persistType)) )
309  {
310  useInternalStruct = false;
311  }
312  if( false == ((0 < m_maxIterations) && (10 > m_maxIterations)) )
313  {
314  useInternalStruct = false;
315  }
316  if( false == ((0 < m_loggingLevel) && (5 > m_loggingLevel)) )
317  {
318  useInternalStruct = false;
319  }
320 
321 // check if internal struct shall be used
322  if( VmbBoolTrue == useInternalStruct )
323  {
324  VmbFeaturePersistSettings_t newSettings;
325  newSettings.persistType = m_persistType;
326  newSettings.maxIterations = m_maxIterations;
327  newSettings.loggingLevel = m_loggingLevel;
328  err = SaveCameraSettings( strFileName.c_str(), &newSettings );
329  }
330  else
331  {
332  err = SaveCameraSettings( strFileName.c_str(), pSettings );
333  }
334 
335  return err;
336 }
337 
338 inline VmbErrorType Camera::LoadCameraSettings( std::string strFileName, VmbFeaturePersistSettings_t *pSettings ) const
339 {
341 
342 // parameter check
343  if( true == strFileName.empty() )
344  {
345  return VmbErrorBadParameter;
346  }
347 
348 // check internal settings struct variables
349  VmbBool_t useInternalStruct = true;
350  if( false == ((0 <= m_persistType) && (3 > m_persistType)) )
351  {
352  useInternalStruct = false;
353  }
354  if( false == ((0 < m_maxIterations) && (10 > m_maxIterations)) )
355  {
356  useInternalStruct = false;
357  }
358  if( false == ((0 < m_loggingLevel) && (5 > m_loggingLevel)) )
359  {
360  useInternalStruct = false;
361  }
362 
363 // check if internal struct shall be used
364  if( VmbBoolTrue == useInternalStruct )
365  {
366  VmbFeaturePersistSettings_t newSettings;
367  newSettings.persistType = m_persistType;
368  newSettings.maxIterations = m_maxIterations;
369  newSettings.loggingLevel = m_loggingLevel;
370  err = LoadCameraSettings( strFileName.c_str(), &newSettings );
371  }
372  else
373  {
374  err = LoadCameraSettings( strFileName.c_str(), pSettings );
375  }
376 
377  return err;
378 }
379 
380 #endif
char VmbBool_t
VmbUint32_t loggingLevel
Definition: VimbaC.h:1890
VmbUint32_t maxIterations
Definition: VimbaC.h:1889
VmbErrorType
VmbFeaturePersist_t persistType
Definition: VimbaC.h:1888
unsigned long long VmbUint64_t
std::vector< FramePtr > FramePtrVector
Definition: Frame.h:335
std::vector< VmbUint64_t > Uint64Vector
std::vector< VmbUchar_t > UcharVector
unsigned int VmbUint32_t


avt_vimba_camera
Author(s): Miquel Massot , Allied Vision Technologies
autogenerated on Mon Jun 10 2019 12:50:38