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 
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 #ifndef AVT_VMBAPI_CAMERA_HPP
29 #define AVT_VMBAPI_CAMERA_HPP
30 
31 //
32 // Inline wrapper functions that allocate memory for STL objects in the application's context
33 // and to pass data across DLL boundaries using arrays
34 //
35 
36 // HINT: This information remains static throughout the object's lifetime
37 inline VmbErrorType Camera::GetID( std::string &rStrID ) const
38 {
39  VmbErrorType res;
40  VmbUint32_t nLength;
41 
42  res = GetID( NULL, nLength );
43  if ( VmbErrorSuccess == res )
44  {
45  if ( 0 != nLength )
46  {
47  try
48  {
49  std::vector<std::string::value_type>tmpID( nLength + 1,'\0');
50  res = GetID( &tmpID[0], nLength );
51  if( VmbErrorSuccess == res)
52  {
53  rStrID = &*tmpID.begin();
54  }
55  }
56  catch(...)
57  {
58  res = VmbErrorResources;
59  }
60  }
61  else
62  {
63  rStrID.clear();
64  }
65  }
66 
67  return res;
68 }
69 
70 // HINT: This information remains static throughout the object's lifetime
71 inline VmbErrorType Camera::GetName( std::string &rStrName ) const
72 {
73  VmbErrorType res;
74  VmbUint32_t nLength;
75 
76  res = GetName( NULL, nLength );
77  if ( VmbErrorSuccess == res )
78  {
79  if( 0 != nLength)
80  {
81  try
82  {
83  std::vector<std::string::value_type> tmpName( nLength + 1,'\0' );
84  res = GetName( &tmpName[0], nLength );
85  if( VmbErrorSuccess == res)
86  {
87  rStrName = &*tmpName.begin();
88  }
89  }
90  catch(...)
91  {
92  res = VmbErrorResources;
93  }
94  }
95  else
96  {
97  rStrName.clear();
98  }
99  }
100 
101  return res;
102 }
103 
104 // HINT: This information remains static throughout the object's lifetime
105 inline VmbErrorType Camera::GetModel( std::string &rStrModel ) const
106 {
107  VmbErrorType res;
108  VmbUint32_t nLength;
109 
110  res = GetModel( NULL, nLength );
111  if ( VmbErrorSuccess == res )
112  {
113  if( 0 != nLength)
114  {
115  try
116  {
117  std::vector<std::string::value_type> tmpModel( nLength + 1,'\0');
118  res = GetModel( &tmpModel[0], nLength );
119  if( VmbErrorSuccess == res )
120  {
121  rStrModel = &*tmpModel.begin();
122  }
123  }
124  catch(...)
125  {
126  res = VmbErrorResources;
127  }
128  }
129  else
130  {
131  rStrModel.clear();
132  }
133  }
134 
135  return res;
136 }
137 
138 // HINT: This information remains static throughout the object's lifetime
139 inline VmbErrorType Camera::GetSerialNumber( std::string &rStrSerial ) const
140 {
141  VmbErrorType res;
142  VmbUint32_t nLength;
143 
144  res = GetSerialNumber( NULL, nLength );
145  if ( VmbErrorSuccess == res )
146  {
147  if ( 0 != nLength )
148  {
149  try
150  {
151  std::vector<std::string::value_type> tmpSerial( nLength + 1,'\0');
152  res = GetSerialNumber( &tmpSerial[0], nLength );
153  if( VmbErrorSuccess == res )
154  {
155  rStrSerial = &*tmpSerial.begin();
156  }
157  }
158  catch(...)
159  {
160  res = VmbErrorResources;
161  }
162  }
163  else
164  {
165  rStrSerial.clear();
166  }
167  }
168 
169  return res;
170 }
171 
172 // HINT: This information remains static throughout the object's lifetime
173 inline VmbErrorType Camera::GetInterfaceID( std::string &rStrInterfaceID ) const
174 {
175  VmbErrorType res;
176  VmbUint32_t nLength;
177 
178  res = GetInterfaceID( NULL, nLength );
179  if ( VmbErrorSuccess == res )
180  {
181  if ( 0 != nLength )
182  {
183  try
184  {
185  std::vector<std::string::value_type> tmpID( nLength + 1,'\0');
186  res = GetInterfaceID( &tmpID[0], nLength );
187  if( VmbErrorSuccess == res )
188  {
189  rStrInterfaceID = &*tmpID.begin();
190  }
191  }
192  catch(...)
193  {
194  res = VmbErrorResources;
195  }
196  }
197  else
198  {
199  rStrInterfaceID.clear();
200  }
201  }
202 
203  return res;
204 }
205 
206 inline VmbErrorType Camera::AcquireMultipleImages( FramePtrVector &rFrames, VmbUint32_t nTimeout )
207 {
208  VmbErrorType res;
209  VmbUint32_t i;
210  res = AcquireMultipleImages( rFrames, nTimeout, i );
211  if ( rFrames.size() != i )
212  {
213  res = VmbErrorInternalFault;
214  }
215 
216  return res;
217 }
218 inline VmbErrorType Camera::AcquireMultipleImages( FramePtrVector &rFrames, VmbUint32_t nTimeout, VmbUint32_t &rNumFramesCompleted )
219 {
220  if ( true == rFrames.empty() )
221  {
222  return VmbErrorBadParameter;
223  }
224 
225  return AcquireMultipleImages( &rFrames[0], (VmbUint32_t)rFrames.size(), nTimeout, &rNumFramesCompleted );
226 }
227 
228 // HINT: Size of address determines how many registers to read. Size of data has to be large enough to hold the requested information
229 inline VmbErrorType Camera::ReadRegisters( const Uint64Vector &rAddresses, Uint64Vector &rBuffer ) const
230 {
231  VmbUint32_t i;
232  return ReadRegisters( rAddresses, rBuffer, i );
233 }
234 inline VmbErrorType Camera::ReadRegisters( const Uint64Vector &rAddresses, Uint64Vector &rBuffer, VmbUint32_t &rCompletedReads ) const
235 {
236  if ( true == rAddresses.empty()
237  || true == rBuffer.empty()
238  || rAddresses.size() > rBuffer.size() )
239  {
240  return VmbErrorBadParameter;
241  }
242  return ReadRegisters( &rAddresses[0], (VmbUint32_t)rAddresses.size(), &rBuffer[0], &rCompletedReads );
243 }
244 
245 // HINT: Size of address determines how many registers to write.
246 inline VmbErrorType Camera::WriteRegisters( const Uint64Vector &rAddresses, const Uint64Vector &rBuffer )
247 {
248  VmbUint32_t i;
249  return WriteRegisters( rAddresses, rBuffer, i );
250 }
251 inline VmbErrorType Camera::WriteRegisters( const Uint64Vector &rAddresses, const Uint64Vector &rBuffer, VmbUint32_t &rCompletedWrites )
252 {
253  if ( true == rAddresses.empty()
254  || true == rBuffer.empty()
255  || rAddresses.size() != rBuffer.size() )
256  {
257  return VmbErrorBadParameter;
258  }
259 
260  return WriteRegisters( &rAddresses[0], (VmbUint32_t)rAddresses.size(), &rBuffer[0], &rCompletedWrites );
261 }
262 
263 // HINT: Size of buffer determines how many bytes to read.
264 inline VmbErrorType Camera::ReadMemory( const VmbUint64_t &rAddress, UcharVector &rBuffer ) const
265 {
266  VmbUint32_t i;
267  return ReadMemory( rAddress, rBuffer, i );
268 }
269 inline VmbErrorType Camera::ReadMemory( const VmbUint64_t &rAddress, UcharVector &rBuffer, VmbUint32_t &rCompletedReads ) const
270 {
271  if ( true == rBuffer.empty() )
272  {
273  return VmbErrorBadParameter;
274  }
275 
276  return ReadMemory( rAddress, &rBuffer[0], (VmbUint32_t)rBuffer.size(), &rCompletedReads );
277 }
278 
279 // HINT: Size of buffer determines how many bytes to write.
280 inline VmbErrorType Camera::WriteMemory( const VmbUint64_t &rAddress, const UcharVector &rBuffer )
281 {
282  VmbUint32_t i;
283  return WriteMemory( rAddress, rBuffer, i );
284 }
285 inline VmbErrorType Camera::WriteMemory( const VmbUint64_t &rAddress, const UcharVector &rBuffer, VmbUint32_t &rCompletedWrites )
286 {
287  if ( true == rBuffer.empty() )
288  {
289  return VmbErrorBadParameter;
290  }
291 
292  return WriteMemory( rAddress, &rBuffer[0], (VmbUint32_t)rBuffer.size(), &rCompletedWrites );
293 }
294 
295 inline VmbErrorType Camera::SaveCameraSettings( std::string strFileName, VmbFeaturePersistSettings_t *pSettings ) const
296 {
297 // parameter check
298  if( true == strFileName.empty() )
299  {
300  return VmbErrorBadParameter;
301  }
302 
303  return SaveCameraSettings( strFileName.c_str(), pSettings );
304 }
305 
306 inline VmbErrorType Camera::LoadCameraSettings( std::string strFileName, VmbFeaturePersistSettings_t *pSettings ) const
307 {
308 // parameter check
309  if( true == strFileName.empty() )
310  {
311  return VmbErrorBadParameter;
312  }
313 
314  return LoadCameraSettings( strFileName.c_str(), pSettings );
315 }
316 
317 #endif
VmbErrorType
unsigned long long VmbUint64_t
std::vector< FramePtr > FramePtrVector
Definition: Frame.h:337
std::vector< VmbUint64_t > Uint64Vector
std::vector< VmbUchar_t > UcharVector
unsigned int VmbUint32_t


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