Camera.cpp
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.cpp
10 
11  Description: Implementation of 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 #pragma warning(disable:4996)
28 #include <sstream>
29 #pragma warning(default:4996)
30 #include <cstring>
31 
33 
38 #include <VimbaCPP/Source/Helper.h>
40 
41 namespace AVT {
42 namespace VmbAPI {
43 
44 // Method: GetFeatureValueInt
45 //
46 //Purpose: helper function to read integer value from camera.
47 //
48 // Parameters:
49 //
50 // [in] cam camera to get integer value from
51 // [in] name name of the feature
52 // [out] val returns integer value of feature on VmbErrorSuccess
53 //
54 VmbErrorType GetFeatureValueInt( Camera&cam,const char* name, VmbInt64_t &val)
55 {
56  if( NULL == name)
57  {
58  LOG_FREE_TEXT("feature name is NULL");
59  return VmbErrorBadParameter;
60  }
61  FeaturePtr pFeature;
62  VmbErrorType res = cam.GetFeatureByName( name, pFeature );
63  if ( VmbErrorSuccess != res )
64  {
65  LOG_FREE_TEXT( std::string("Could not get feature by name for ") + name);
66  return res;
67  }
68  res = SP_ACCESS(pFeature)->GetValue( val );
69  if( VmbErrorSuccess != res)
70  {
71  LOG_FREE_TEXT( std::string("Could not get value of feature ") + name);
72  }
73  return res;
74 }
75 //
76 // Method: RunFeatureCommand
77 //
78 // Purpose: helper to run a command feature for camera.
79 //
80 // Parameters:
81 //
82 // [in] cam camera to run command on
83 // [in] name command name to run
84 //
85 VmbErrorType RunFeatureCommand( Camera&cam,const char* name)
86 {
87  if( NULL == name)
88  {
89  LOG_FREE_TEXT("feature name is NULL");
90  return VmbErrorBadParameter;
91  }
92  FeaturePtr pFeature;
93  VmbErrorType res = cam.GetFeatureByName( name, pFeature );
94  if ( VmbErrorSuccess != res )
95  {
96  LOG_FREE_TEXT( std::string("Could not get feature by name for ") + name);
97  return res;
98  }
99  res = SP_ACCESS(pFeature)->RunCommand();
100  if( VmbErrorSuccess != res)
101  {
102  LOG_FREE_TEXT( std::string("Could not run feature command ") + name);
103  }
104  return res;
105 }
106 
107 // small helper class that keeps track of resources needed for image acquisition
109 {
110 private:
111  //clean up tasks
113  {
118  };
119  typedef std::vector<tear_down_tasks> task_storage;
120  task_storage m_Tasks; // storage for cleanup tasks
124  {
125  tear_down_tasks current_task = m_Tasks.back();
126  m_Tasks.pop_back();
127  return current_task;
128  }
130  // Method: SetupFrame
131  //
132  // Purpose: prepare a frame with given payload size.
133  //
134  // Parameters:
135  // [in,out] pFrame a frame pointer that can point to Null
136  // [in] payload_size payload size for frame
137  //
138  static VmbErrorType SetupFrame(FramePtr &pFrame, VmbInt64_t PayloadSize)
139  {
140  if( PayloadSize <= 0)
141  {
142  LOG_FREE_TEXT("payload size has to be larger than 0");
143  return VmbErrorBadParameter;
144  }
145  VmbUint32_t buffer_size(0);
146  VmbErrorType Result;
147  if( ! SP_ISNULL( pFrame) ) // if frame already exists, check its buffer size
148  {
149  Result = SP_ACCESS( pFrame) ->GetBufferSize(buffer_size);
150  if( VmbErrorSuccess != Result)
151  {
152  LOG_FREE_TEXT("Could not get frame buffer size");
153  return Result;
154  }
155  if( buffer_size >= PayloadSize) // buffer is large enough, no need to create new frame
156  {
157  return VmbErrorSuccess;
158  }
159  }
160  try
161  {
162  SP_SET( pFrame, new Frame( PayloadSize));
163  if( SP_ISNULL( pFrame) ) // in case we find a not throwing new
164  {
165  LOG_FREE_TEXT("error allocating frame");
166  return VmbErrorResources;
167  }
168  }
169  catch(...)
170  {
171  LOG_FREE_TEXT("error allocating frame");
172  return VmbErrorResources;
173  }
174  return VmbErrorSuccess;
175  }
176 public:
177  // construct helper from camera
179  : m_Camera( Cam)
180  {}
181  // destroy will tear all down
183  {
184  TearDown();
185  }
186  //
187  // Method:: AnnounceFrames
188  //
189  // Purpose: helper to announce a list of frames to the camera.
190  //
191  // Parameters:
192  //
193  // [in] Camera Camera to announce the frames too
194  // [in,out] pFrames storage for frame pointer, if they are NULL or have no sufficient space the frames will be created
195  // [in] nFrameCount number of frame pointers in pFrames
196  // [in] nPayloadSize payload size for one frame
197  // [out] nFramesAnnounced returns number of successful announced frames
198  // Returns:
199  //
200  // the first error that occurred or VmbErrorSuccess if non occurred
201  // Details: note the function will try to construct and announce nFrameCount frames t o the camera, even if some of them can not be created or announced, only if nFramesAnnounced == 0 the function was unsuccessful
202  //
203  static VmbErrorType AnnounceFrames(Camera &Camera, FramePtr *pFrames, VmbUint32_t nFrameCount, VmbInt64_t nPayloadSize, VmbUint32_t &nFramesAnnounced)
204  {
205  VmbErrorType Result = VmbErrorSuccess;
206  nFramesAnnounced = 0;
207  for( VmbUint32_t FrameNumber= 0; FrameNumber < nFrameCount; ++FrameNumber)
208  {
209  VmbErrorType LocalResult = SetupFrame( pFrames[ FrameNumber ], nPayloadSize); //< try to init frame
210  if( VmbErrorSuccess == LocalResult)
211  {
212  LocalResult = Camera.AnnounceFrame( pFrames[ FrameNumber] ); //< announce frame if successful initialized
213  if ( VmbErrorSuccess == LocalResult )
214  {
215  ++nFramesAnnounced;
216  }
217  else
218  {
219  std::stringstream strMsg("Could only successfully announce ");
220  strMsg << nFramesAnnounced << " of " << nFrameCount << " frames. Will continue with queuing those.";
221  LOG_FREE_TEXT( strMsg.str() );
222  }
223  }
224  if( VmbErrorSuccess == Result )
225  {
226  Result = LocalResult;
227  }
228  }
229  return Result;
230  }
231  //
232  // Method: AnnounceFrames
233  //
234  // Purpose: announce a FramePtrVector to the camera.
235  //
236  // Parameters:
237  // [in] Camera camera to announce the frames to
238  // [in,out] Frames vector of frame pointers that will contain the announced frames on return, can be empty on input
239  // [in] nBufferCount number of frames to announce, if nBufferCount > Frames.size() on return, some frames could not be announced
240  // [in] nPayloadSize frame payload size
241  // [in] Observer observer to attach to frames
242  //
243  static VmbErrorType AnnounceFrames(Camera &Camera, FramePtrVector &Frames, VmbUint32_t nBufferCount, VmbInt64_t nPayloadSize, const IFrameObserverPtr& Observer)
244  {
245  try
246  {
247  Frames.reserve( nBufferCount);
248  }
249  catch(...)
250  {
251  LOG_FREE_TEXT("could not allocate frames");
252  return VmbErrorResources;
253  }
254  VmbErrorType Result = VmbErrorSuccess;
255  for( VmbUint32_t i=0; i < nBufferCount; ++i)
256  {
257  FramePtr tmpFrame;
258  VmbErrorType LocalResult = SetupFrame( tmpFrame, nPayloadSize );
259  if( ! SP_ISNULL( tmpFrame) )
260  {
261  LocalResult = SP_ACCESS( tmpFrame)->RegisterObserver( Observer );
262  if( VmbErrorSuccess == LocalResult )
263  {
264  LocalResult = Camera.AnnounceFrame( tmpFrame);
265  if( VmbErrorSuccess == LocalResult )
266  {
267  Frames.push_back( tmpFrame );
268  }
269  else
270  {
271  LOG_FREE_TEXT("could not announce frame");
272  }
273  }
274  else
275  {
276  LOG_FREE_TEXT("could not register frame observer");
277  }
278  }
279  else
280  {
281  LOG_FREE_TEXT("could not allocate frame");
282  }
283  if( VmbErrorSuccess == Result)
284  {
285  Result = LocalResult;
286  }
287  }
288  return Result;
289  }
290  //
291  // Method: Prepare
292  //
293  // Purpose: prepare image grab for single image.
294  //
295  // Parameters:
296  //
297  // [in,out] pFrame frame to hold the image
298  // [in] PayloadSize frame payload size
299  //
300  VmbErrorType Prepare(FramePtr &pFrame, VmbInt64_t PayloadSize)
301  {
302  VmbErrorType res;
303  res = SetupFrame( pFrame, PayloadSize); // init frame if necessary
304  if ( VmbErrorSuccess != res )
305  {
306  LOG_FREE_TEXT("Could not create frame");
307  return res;
308  }
309  res = m_Camera.AnnounceFrame( pFrame ); // announce frame to camera
310  if ( VmbErrorSuccess != res )
311  {
312  LOG_FREE_TEXT("Could not Announce frame");
313  return res;
314  }
315  m_Tasks.push_back( RevokeFrame); // if successful announced we need to revoke frames
316  res = m_Camera.StartCapture(); // start capture logic
317  if ( VmbErrorSuccess != res )
318  {
319  LOG_FREE_TEXT( "Could not Start Capture" );
320  return res;
321  }
322  m_Tasks.push_back( EndCapture); // if capture logic is started we need end capture task
323  res = m_Camera.QueueFrame( pFrame ); // queue frame in processing logic
324  if ( VmbErrorSuccess != res )
325  {
326  LOG_FREE_TEXT( "Could not queue frame");
327  return res;
328  }
329  m_Tasks.pop_back();
330  m_Tasks.push_back( FlushQueue); // if frame queued we need flush queue task
331  m_Tasks.push_back( EndCapture);
332  FeaturePtr pFeature;
333  res = RunFeatureCommand( m_Camera, "AcquisitionStart" ); // start acquisition
334  if ( VmbErrorSuccess != res )
335  {
336  LOG_FREE_TEXT("Could not run command AcquisitionStart");
337  return res;
338  }
339  m_Tasks.push_back( AcquisitionStop);
340  return res;
341  }
342  // Method: Prepare
343  //
344  // Purpose: prepare image acquisition for multiple frames.
345  //
346  // Parameters:
347  //
348  // [in,out] pFrames non NULL pointer to field of frame pointers (can point to NULL) that hold the captured images
349  // [in] nFrameCount number of frames in vector
350  // [in] nPayLoadSize payload size
351  // [out] nFramesQueued returns number of successful queued images
352  //
353  VmbErrorType Prepare(FramePtr *pFrames, VmbUint32_t nFrameCount, VmbInt64_t nPayloadSize, VmbUint32_t &nFramesQueued )
354  {
355  if( NULL == pFrames || 0 == nFrameCount) // sanity check
356  {
357  return VmbErrorBadParameter;
358  }
359  nFramesQueued = 0;
360  VmbErrorType Result = VmbErrorSuccess;
361  VmbUint32_t FramesAnnounced = 0;
362  Result = AnnounceFrames( m_Camera, pFrames, nFrameCount, nPayloadSize, FramesAnnounced);
363  if( 0 == FramesAnnounced)
364  {
365  return Result;
366  }
367  m_Tasks.push_back( RevokeFrame); // add cleanup task for announced frames
368  Result = m_Camera.StartCapture(); // start capture logic
369  if ( VmbErrorSuccess != Result)
370  {
371  LOG_FREE_TEXT( "Could not Start Capture" );
372  return Result;
373  }
374  m_Tasks.push_back( EndCapture); // add cleanup task to end capture
375  for( VmbUint32_t FrameNumber = 0; FrameNumber < FramesAnnounced; ++FrameNumber)
376  {
377  Result = m_Camera.QueueFrame( pFrames[ FrameNumber ] ); // try queuing frame
378  if ( VmbErrorSuccess != Result )
379  {
380  std::stringstream strMsg("Could only successfully queue ");
381  strMsg << nFramesQueued << " of " << nFrameCount << " frames. Will continue with filling those.";
382  LOG_FREE_TEXT( strMsg.str() );
383  break;
384  }
385  else
386  {
387  ++nFramesQueued;
388  }
389  }
390  if( 0 == nFramesQueued) // we cannot capture anything, there are no frames queued
391  {
392  return Result;
393  }
394  m_Tasks.pop_back();
395  m_Tasks.push_back( FlushQueue); // if any frame was queued we need a cleanup task
396  m_Tasks.push_back( EndCapture);
397  FeaturePtr pFeature;
398  Result = RunFeatureCommand( m_Camera, "AcquisitionStart" ); // start acquisition logic
399  if ( VmbErrorSuccess != Result )
400  {
401  LOG_FREE_TEXT("Could not run command AcquisitionStart");
402  return Result;
403  }
404  m_Tasks.push_back( AcquisitionStop);
405  return Result;
406  }
407  //
408  // Method: TearDown
409  //
410  // Purpose: free all acquired resources.
411  //
413  {
415  while( ! m_Tasks.empty() )
416  {
417  VmbErrorType local_result = VmbErrorSuccess;
418  switch( GetTask() )
419  {
420  case AcquisitionStop:
421  local_result = RunFeatureCommand(m_Camera, "AcquisitionStop");
422  if( VmbErrorSuccess != local_result)
423  {
424  LOG_FREE_TEXT("Could not run command AquireStop");
425  }
426  break;
427  case EndCapture:
428  local_result = m_Camera.EndCapture();
429  if( VmbErrorSuccess != local_result)
430  {
431  LOG_FREE_TEXT("Could Not run EndCapture");
432  }
433  break;
434  case FlushQueue:
435  local_result = m_Camera.FlushQueue();
436  if( VmbErrorSuccess != local_result)
437  {
438  LOG_FREE_TEXT("Could not run Flush Queue command");
439  }
440  break;
441  case RevokeFrame:
442  local_result = m_Camera.RevokeAllFrames();
443  if( VmbErrorSuccess != local_result)
444  {
445  LOG_FREE_TEXT("Could Not Run Revoke Frames command");
446  }
447  break;
448  }
449  if( VmbErrorSuccess == res)
450  res = local_result;
451  }
452  return res;
453  }
454 };
455 
456 
458 {
459  // Copy of camera infos
460  struct CameraInfo
461  {
462  std::string cameraIdString; // Unique identifier for each camera
463  std::string cameraIdStringGigE; // GigE cameras can also be opened by IP or MAC address
464  std::string cameraName; // Name of the camera
465  std::string modelName; // Model name
466  std::string serialString; // Serial number
467  std::string interfaceIdString; // Unique value for each interface or bus
468  } m_cameraInfo;
469 
470  VmbInterfaceType m_eInterfaceType; // The type of the interface the camera is connected to
471 
474 
477 
481 
482  VmbErrorType AppendFrameToVector( const FramePtr &frame );
483 };
484 
486 {
487  // No default ctor
488 }
489 
491 {
492  // No copy ctor
493 }
494 
496 {
497  // No assignment operator
498  return *this;
499 }
500 
501 Camera::Camera( const char *pID,
502  const char *pName,
503  const char *pModel,
504  const char *pSerialNumber,
505  const char *pInterfaceID,
506  VmbInterfaceType eInterfaceType )
507  : m_pImpl( new Impl() )
508 {
509  m_pImpl->m_cameraInfo.cameraIdString.assign( pID ? pID : "" );
510  // TODO: Remove this with interface change
511  const char* pIDGigE = strstr( pID, AVT_IP_OR_MAC_ADDRESS);
512  if ( pIDGigE )
513  {
514  m_pImpl->m_cameraInfo.cameraIdStringGigE.assign( pIDGigE );
517  }
518  m_pImpl->m_cameraInfo.cameraName.assign( pName ? pName : "" );
519  m_pImpl->m_cameraInfo.interfaceIdString.assign( pInterfaceID ? pInterfaceID : "" );
520  m_pImpl->m_cameraInfo.modelName.assign( pModel ? pModel : "" );
521  m_pImpl->m_cameraInfo.serialString.assign( pSerialNumber ? pSerialNumber : "" );
522  m_pImpl->m_eInterfaceType = eInterfaceType;
523  m_pImpl->m_bAllowQueueFrame = true;
525  m_pImpl->m_persistType = -1;
526  m_pImpl->m_maxIterations = -1;
527  m_pImpl->m_loggingLevel = -1;
528 }
529 
531 {
532  Close();
533 
534  delete m_pImpl;
535 }
536 
538 {
539  VmbError_t res;
540  VmbHandle_t hHandle;
541 
542  if ( false == m_pImpl->m_cameraInfo.cameraIdStringGigE.empty() )
543  {
544  res = VmbCameraOpen( m_pImpl->m_cameraInfo.cameraIdStringGigE.c_str(), (VmbAccessMode_t)eAccessMode, &hHandle );
545  }
546  else
547  {
548  res = VmbCameraOpen( m_pImpl->m_cameraInfo.cameraIdString.c_str(), (VmbAccessMode_t)eAccessMode, &hHandle );
549  }
550 
551  if ( VmbErrorSuccess == res )
552  {
553  SetHandle( hHandle );
554  }
555 
556  return (VmbErrorType)res;
557 }
558 
560 {
562 
563  if ( NULL != GetHandle() )
564  {
565  if ( 0 < m_pImpl->m_frameHandlers.Vector.size()
566  && ( VmbErrorSuccess != EndCapture()
569  {
570  // Do some logging
571  LOG_FREE_TEXT( "Could not successfully revoke all frames")
572  }
573 
574  Reset();
575 
576  res = VmbCameraClose( GetHandle() );
577 
578  RevokeHandle();
579  }
580 
581  return (VmbErrorType)res;
582 }
583 
584 VmbErrorType Camera::GetID( char * const pStrID, VmbUint32_t &rnLength ) const
585 {
586  VmbErrorType res;
587 
588  if ( NULL == pStrID )
589  {
590  rnLength = (VmbUint32_t)m_pImpl->m_cameraInfo.cameraIdString.length();
591  res = VmbErrorSuccess;
592  }
593  else if ( m_pImpl->m_cameraInfo.cameraIdString.length() <= rnLength )
594  {
595  std::copy( m_pImpl->m_cameraInfo.cameraIdString.begin(), m_pImpl->m_cameraInfo.cameraIdString.end(), pStrID );
596  pStrID[m_pImpl->m_cameraInfo.cameraIdString.length()] = '\0';
597  rnLength = (VmbUint32_t)m_pImpl->m_cameraInfo.cameraIdString.length();
598  res = VmbErrorSuccess;
599  }
600  else
601  {
602  res = VmbErrorMoreData;
603  }
604 
605  return res;
606 }
607 
608 VmbErrorType Camera::GetName( char * const pStrName, VmbUint32_t &rnLength ) const
609 {
610  VmbErrorType res;
611 
612  if ( NULL == pStrName )
613  {
614  rnLength = (VmbUint32_t)m_pImpl->m_cameraInfo.cameraName.length();
615  res = VmbErrorSuccess;
616  }
617  else if ( m_pImpl->m_cameraInfo.cameraName.length() <= rnLength )
618  {
619  std::copy( m_pImpl->m_cameraInfo.cameraName.begin(), m_pImpl->m_cameraInfo.cameraName.end(), pStrName );
620  pStrName[m_pImpl->m_cameraInfo.cameraName.length()] = '\0';
621  rnLength = (VmbUint32_t)m_pImpl->m_cameraInfo.cameraName.length();
622  res = VmbErrorSuccess;
623  }
624  else
625  {
626  res = VmbErrorMoreData;
627  }
628 
629  return res;
630 }
631 
632 VmbErrorType Camera::GetModel( char * const pStrModel, VmbUint32_t &rnLength ) const
633 {
634  VmbErrorType res;
635 
636  if ( NULL == pStrModel )
637  {
638  rnLength = (VmbUint32_t)m_pImpl->m_cameraInfo.modelName.length();
639  res = VmbErrorSuccess;
640  }
641  else if ( m_pImpl->m_cameraInfo.modelName.length() <= rnLength )
642  {
643  std::copy( m_pImpl->m_cameraInfo.modelName.begin(), m_pImpl->m_cameraInfo.modelName.end(), pStrModel );
644  pStrModel[m_pImpl->m_cameraInfo.modelName.length()] = '\0';
645  rnLength = (VmbUint32_t)m_pImpl->m_cameraInfo.modelName.length();
646  res = VmbErrorSuccess;
647  }
648  else
649  {
650  res = VmbErrorMoreData;
651  }
652 
653  return res;
654 }
655 
656 VmbErrorType Camera::GetSerialNumber( char * const pStrSerial, VmbUint32_t &rnLength ) const
657 {
658  VmbErrorType res;
659 
660  if ( NULL == pStrSerial )
661  {
662  rnLength = (VmbUint32_t)m_pImpl->m_cameraInfo.serialString.length();
663  res = VmbErrorSuccess;
664  }
665  else if ( m_pImpl->m_cameraInfo.serialString.length() <= rnLength )
666  {
667  std::copy( m_pImpl->m_cameraInfo.serialString.begin(), m_pImpl->m_cameraInfo.serialString.end(), pStrSerial );
668  pStrSerial[m_pImpl->m_cameraInfo.serialString.length()] = '\0';
669  rnLength = (VmbUint32_t)m_pImpl->m_cameraInfo.serialString.length();
670  res = VmbErrorSuccess;
671  }
672  else
673  {
674  res = VmbErrorMoreData;
675  }
676 
677  return res;
678 }
679 
680 VmbErrorType Camera::GetInterfaceID( char * const pStrInterfaceID, VmbUint32_t &rnLength ) const
681 {
682  VmbErrorType res;
683 
684  if ( NULL == pStrInterfaceID )
685  {
686  rnLength = (VmbUint32_t)m_pImpl->m_cameraInfo.interfaceIdString.length();
687  res = VmbErrorSuccess;
688  }
689  else if ( m_pImpl->m_cameraInfo.interfaceIdString.length() <= rnLength )
690  {
691  std::copy( m_pImpl->m_cameraInfo.interfaceIdString.begin(), m_pImpl->m_cameraInfo.interfaceIdString.end(), pStrInterfaceID );
692  pStrInterfaceID[m_pImpl->m_cameraInfo.interfaceIdString.length()] = '\0';
693  rnLength = (VmbUint32_t)m_pImpl->m_cameraInfo.interfaceIdString.length();
694  res = VmbErrorSuccess;
695  }
696  else
697  {
698  res = VmbErrorMoreData;
699  }
700 
701  return res;
702 }
703 
705 {
706  reInterfaceType = m_pImpl->m_eInterfaceType;
707 
708  return VmbErrorSuccess;
709 }
710 
712 {
713  VmbError_t res;
714  VmbCameraInfo_t info;
715 
716  if ( false == m_pImpl->m_cameraInfo.cameraIdStringGigE.empty() )
717  {
718  res = VmbCameraInfoQuery( m_pImpl->m_cameraInfo.cameraIdStringGigE.c_str(), &info, sizeof( VmbCameraInfo_t ));
719  }
720  else
721  {
722  res = VmbCameraInfoQuery( m_pImpl->m_cameraInfo.cameraIdString.c_str(), &info, sizeof( VmbCameraInfo_t ));
723  }
724 
725  if ( VmbErrorSuccess == res )
726  {
727  rePermittedAccess = (VmbAccessModeType)info.permittedAccess;
728  }
729 
730  return (VmbErrorType)res;
731 }
732 
733 VmbErrorType Camera::ReadRegisters( const VmbUint64_t *pAddressArray, VmbUint32_t nAddressSize, VmbUint64_t *pDataArray, VmbUint32_t *pCompletedReads ) const
734 {
735  return static_cast<VmbErrorType>( VmbRegistersRead( GetHandle(), nAddressSize, pAddressArray, pDataArray, pCompletedReads ) );
736 }
737 
738 VmbErrorType Camera::WriteRegisters( const VmbUint64_t *pAddressArray, VmbUint32_t nAddressSize, const VmbUint64_t *pDataArray, VmbUint32_t *pCompletedWrites )
739 {
740  return static_cast<VmbErrorType>( VmbRegistersWrite( GetHandle(), nAddressSize, pAddressArray, pDataArray, pCompletedWrites ) );
741 }
742 
743 VmbErrorType Camera::ReadMemory( const VmbUint64_t address, VmbUchar_t *pBuffer, VmbUint32_t nBufferSize, VmbUint32_t *pSizeComplete ) const
744 {
745  return static_cast<VmbErrorType>( VmbMemoryRead( GetHandle(), address, nBufferSize, (char*)pBuffer, pSizeComplete ) );
746 }
747 
748 VmbErrorType Camera::WriteMemory( const VmbUint64_t address, const VmbUchar_t *pBuffer, VmbUint32_t nBufferSize, VmbUint32_t *pSizeComplete )
749 {
750  return static_cast<VmbErrorType>( VmbMemoryWrite( GetHandle(), address, nBufferSize, (char *)pBuffer, pSizeComplete ) );
751 }
752 
753 //Get one image synchronously.
755 {
756  VmbErrorType res;
757  VmbInt64_t PayloadSize;
758  FeaturePtr pFeature;
759 
760  res = GetFeatureValueInt( *this, "PayloadSize", PayloadSize );
761  if ( VmbErrorSuccess == res )
762  {
763  AcquireImageHelper AcquireHelper( *this );
764  res = AcquireHelper.Prepare( rFrame, PayloadSize );
765  if ( VmbErrorSuccess == res )
766  {
767  res = (VmbErrorType)VmbCaptureFrameWait( GetHandle(), &(SP_ACCESS( rFrame )->m_pImpl->m_frame), nTimeout );
768  if ( VmbErrorSuccess != res )
769  {
770  LOG_FREE_TEXT( "Could not acquire single image." )
771  }
772  }
773  else
774  {
775  LOG_FREE_TEXT( "Preparing image acquisition failed." );
776  }
777  VmbErrorType local_result = AcquireHelper.TearDown();
778  if( VmbErrorSuccess != local_result )
779  {
780  LOG_FREE_TEXT( "Tear down capture logic failed." )
781  if( VmbErrorSuccess == res)
782  {
783  res = local_result;
784  }
785  }
786  }
787  else
788  {
789  LOG_FREE_TEXT( "Could not get payload size" );
790  }
791 
792  return res;
793 }
794 
795 VmbErrorType Camera::AcquireMultipleImages( FramePtr *pFrames, VmbUint32_t nSize, VmbUint32_t nTimeout, VmbUint32_t *pNumFramesCompleted )
796 {
798 
799  if ( NULL == pFrames
800  || 0 == nSize )
801  {
802  return res;
803  }
804 
805  if ( NULL != pNumFramesCompleted )
806  {
807  *pNumFramesCompleted = 0;
808  }
809 
810  VmbInt64_t nPayloadSize;
811  FeaturePtr pFeature;
812 
813  res = GetFeatureValueInt( *this, "PayloadSize", nPayloadSize );
814  if ( VmbErrorSuccess == res )
815  {
816  AcquireImageHelper AquireHelper( *this );
817  VmbUint32_t nFramesQueued = 0;
818  res = AquireHelper.Prepare( pFrames, nSize, nPayloadSize, nFramesQueued);
819 
820  if ( VmbErrorSuccess == res )
821  {
822  for ( VmbUint32_t nFrameCount = 0; nFrameCount <nFramesQueued; ++ nFrameCount )
823  {
824  res = (VmbErrorType)VmbCaptureFrameWait( GetHandle(), &(SP_ACCESS( pFrames[nFrameCount] )->m_pImpl->m_frame), nTimeout );
825  if ( VmbErrorSuccess != res )
826  {
827  std::stringstream strMsg("Could only successfully fill ");
828  strMsg << nFrameCount-1 << " of " << nSize << " frames. Will stop acquisition now.";
829  LOG_FREE_TEXT( strMsg.str() );
830  break;
831  }
832  else if ( NULL != pNumFramesCompleted )
833  {
834  ++(*pNumFramesCompleted);
835  }
836  }
837  VmbErrorType local_res = AquireHelper.TearDown();
838  if( VmbErrorSuccess == res)
839  {
840  res = local_res;
841  }
842  }
843  else
844  {
845  LOG_FREE_TEXT( "Could not start capture" )
846  }
847  }
848  else
849  {
850  LOG_FREE_TEXT( "Could not get feature PayloadSize");
851  }
852 
853  return res;
854 }
855 
856 VmbErrorType Camera::StartContinuousImageAcquisition( int nBufferCount, const IFrameObserverPtr &rObserver )
857 {
858  VmbErrorType res;
859  FramePtrVector Frames;
860  VmbInt64_t nPayloadSize;
861 
862  res = GetFeatureValueInt(*this,"PayloadSize", nPayloadSize );
863  if ( VmbErrorSuccess == res )
864  {
865  res = AcquireImageHelper::AnnounceFrames( *this, Frames, nBufferCount, nPayloadSize, rObserver );
866  if( Frames.empty() )
867  {
868  return res;
869  }
870  res = StartCapture();
871  if ( VmbErrorSuccess == res )
872  {
873  VmbUint32_t FramesQueued = 0;
874  for ( size_t FrameNumber = 0; FrameNumber < Frames.size(); ++ FrameNumber )
875  {
876  VmbErrorType LocalResult = QueueFrame( Frames[ FrameNumber] );
877  if ( VmbErrorSuccess == LocalResult)
878  {
879  ++FramesQueued;
880  }
881  else
882  {
883  LOG_FREE_TEXT( "Could not queue frame" )
884  }
885  if( VmbErrorSuccess == res)
886  {
887  res = LocalResult;
888  }
889  }
890  if( 0 != FramesQueued)
891  {
892  res = RunFeatureCommand(*this, "AcquisitionStart" );
893  if ( VmbErrorSuccess != res )
894  {
895  EndCapture();
896  FlushQueue();
897  RevokeAllFrames();
898  LOG_FREE_TEXT( "Could not start acquisition" )
899  return res;
900  }
901 
902  }
903  else
904  {
905  EndCapture();
906  RevokeAllFrames();
907  LOG_FREE_TEXT( "Could not queue frames" )
908  return res;
909  }
910 
911  }
912  else
913  {
914  RevokeAllFrames();
915  LOG_FREE_TEXT( "Could not start capturing" )
916  }
917  }
918  else
919  {
920  LOG_FREE_TEXT( "Could not get feature PayloadSize" )
921  }
922 
923  return res;
924 }
925 
927 {
928  VmbErrorType res;
929  FeaturePtr pFeature;
930 
931  // Prevent queuing of new frames while stopping
932  {
934  m_pImpl->m_bAllowQueueFrame = false;
935  }
936 
937  res = RunFeatureCommand( *this, "AcquisitionStop" );
938  if ( VmbErrorSuccess != res )
939  {
940  LOG_FREE_TEXT( "Could not run feature AcquisitionStop" )
941  }
942 
943  res = EndCapture();
944  if ( VmbErrorSuccess == res )
945  {
946  res = FlushQueue();
947  if( VmbErrorSuccess != res)
948  {
949  LOG_FREE_TEXT( "Could not flush queue" )
950  }
951  res = RevokeAllFrames();
952  if ( VmbErrorSuccess != res )
953  {
954  LOG_FREE_TEXT( "Could not revoke frames" )
955  }
956  }
957  else
958  {
959  LOG_FREE_TEXT("Could not stop capture, unable to revoke frames")
960  }
961 
962  {
964  m_pImpl->m_bAllowQueueFrame = true;
965  }
966 
967  return res;
968 }
969 
970 VmbErrorType Camera::AnnounceFrame( const FramePtr &frame )
971 {
972  if ( SP_ISNULL( frame ))
973  {
974  return VmbErrorBadParameter;
975  }
976 
977  if ( true == SP_ACCESS( frame )->m_pImpl->m_bAlreadyAnnounced
978  || true == SP_ACCESS( frame )->m_pImpl->m_bAlreadyQueued )
979  {
980  return VmbErrorInvalidCall;
981  }
982 
983  VmbError_t res = VmbFrameAnnounce( GetHandle(), &(SP_ACCESS( frame )->m_pImpl->m_frame), sizeof SP_ACCESS( frame )->m_pImpl->m_frame );
984 
985  if ( VmbErrorSuccess == res )
986  {
987  // Begin write lock frame handler list
989  {
990  res = m_pImpl->AppendFrameToVector( frame ) ;
991  if( VmbErrorSuccess == res )
992  {
993  SP_ACCESS( frame )->m_pImpl->m_bAlreadyAnnounced = true;
994  }
995  else
996  {
997  LOG_FREE_TEXT("could not append frame to internal vector");
998  }
999  // End write lock frame handler list
1001  }
1002  else
1003  {
1004  LOG_FREE_TEXT( "Could not lock announced frame queue for appending frame." );
1005  res = VmbErrorResources;
1006  }
1007  }
1008 
1009  return static_cast<VmbErrorType>( res );
1010 }
1011 
1012 VmbErrorType Camera::RevokeFrame( const FramePtr &frame )
1013 {
1014  if ( SP_ISNULL( frame ))
1015  {
1016  return VmbErrorBadParameter;
1017  }
1018 
1019  VmbError_t res = VmbFrameRevoke( GetHandle(), &(SP_ACCESS( frame )->m_pImpl->m_frame) );
1020 
1021  if ( VmbErrorSuccess == res )
1022  {
1023  // Begin (exclusive) write lock frame handler list
1025  {
1026  // Dequeue, revoke and delete frame
1027  for( FrameHandlerPtrVector::iterator iter = m_pImpl->m_frameHandlers.Vector.begin();
1028  m_pImpl->m_frameHandlers.Vector.end() != iter;)
1029  {
1030  // Begin exclusive write lock frame handler
1031  MutexGuard lockal_lock ( SP_ACCESS((*iter))->Mutex() );
1032  if ( SP_ISEQUAL( frame, SP_ACCESS(( *iter ))->GetFrame() ))
1033  {
1034  SP_ACCESS( frame )->m_pImpl->m_frame.context[FRAME_HDL] = NULL;
1035  SP_ACCESS( frame )->m_pImpl->m_bAlreadyQueued = false;
1036  SP_ACCESS( frame )->m_pImpl->m_bAlreadyAnnounced = false;
1037  // End exclusive write lock frame handler
1038  iter = m_pImpl->m_frameHandlers.Vector.erase( iter );
1039  return VmbErrorSuccess;
1040  }
1041  else
1042  {
1043  ++iter;
1044  }
1045  }
1046 
1047  // End (exclusive) write lock frame handler list
1049  }
1050  else
1051  {
1052  LOG_FREE_TEXT( "Could not lock announced frame queue for removing frame." );
1053  res = VmbErrorResources;
1054  }
1055  }
1056  else
1057  {
1058  LOG_FREE_TEXT( "Could not revoke frames" )
1059  }
1060 
1061  return (VmbErrorType)res;
1062 }
1063 
1065 {
1066  VmbError_t res;
1067 
1068  res = VmbFrameRevokeAll( GetHandle() );
1069 
1070  if ( VmbErrorSuccess == res )
1071  {
1072  // Begin (exclusive) write lock frame handler list
1074  {
1075  // Dequeue, revoke and delete frames
1076  for ( FrameHandlerPtrVector::iterator iter = m_pImpl->m_frameHandlers.Vector.begin();
1077  m_pImpl->m_frameHandlers.Vector.end() != iter;
1078  ++iter )
1079  {
1080  // Begin exclusive write lock frame handler
1081  MutexGuard local_lock( SP_ACCESS((*iter))->Mutex() );
1082  SP_ACCESS( SP_ACCESS(( *iter ))->GetFrame() )->m_pImpl->m_frame.context[FRAME_HDL] = NULL;
1083  SP_ACCESS( SP_ACCESS(( *iter ))->GetFrame() )->m_pImpl->m_bAlreadyQueued = false;
1084  SP_ACCESS (SP_ACCESS(( *iter ))->GetFrame() )->m_pImpl->m_bAlreadyAnnounced = false;
1085  // End exclusive write lock frame handler
1086  }
1087 
1088  m_pImpl->m_frameHandlers.Vector.clear();
1089 
1090  // End exclusive write lock frame handler list
1092  }
1093  else
1094  {
1095  LOG_FREE_TEXT( "Could not lock frame handler list.")
1096  }
1097  }
1098 
1099  return (VmbErrorType)res;
1100 }
1101 
1102 VmbErrorType Camera::QueueFrame( const FramePtr &frame )
1103 {
1104  if ( SP_ISNULL( frame ))
1105  {
1106  return VmbErrorBadParameter;
1107  }
1108 
1110  if ( false == m_pImpl->m_bAllowQueueFrame )
1111  {
1112  LOG_FREE_TEXT( "Queuing of new frames is not possible while flushing and revoking the currently queued frames." );
1113  return VmbErrorInvalidCall;
1114  }
1115 
1116  // HINT: The same frame cannot be queued twice (VmbErrorOther)
1118 
1119  if ( VmbErrorSuccess == res
1120  && false == SP_ACCESS( frame )->m_pImpl->m_bAlreadyQueued )
1121  {
1122  if ( false == SP_ACCESS( frame )->m_pImpl->m_bAlreadyAnnounced )
1123  {
1124  // Begin write lock frame handler list
1126  {
1127  m_pImpl->AppendFrameToVector( frame );
1128  SP_ACCESS( frame )->m_pImpl->m_bAlreadyQueued = true;
1129 
1130  // End write lock frame handler list
1132  }
1133  else
1134  {
1135  LOG_FREE_TEXT( "Could not lock frame queue for appending frame." );
1136  res = VmbErrorResources;
1137  }
1138  }
1139  }
1140 
1141  return static_cast<VmbErrorType>( res );
1142 }
1143 
1145 {
1147 
1148  if ( VmbErrorSuccess == res )
1149  {
1150  // Begin exclusive write lock frame handler list
1152  {
1153  for ( FrameHandlerPtrVector::iterator iter = m_pImpl->m_frameHandlers.Vector.begin();
1154  m_pImpl->m_frameHandlers.Vector.end() != iter;)
1155  {
1156  // Begin exclusive write lock of every single frame handler
1157  MutexPtr tmpMutex = SP_ACCESS((*iter))->Mutex();
1158  SP_ACCESS( tmpMutex )->Lock();
1159  //SP_ACCESS(( *iter)) ->Mutex()->Lock();
1160  // Dequeue frame
1161  SP_ACCESS( SP_ACCESS(( *iter ))->GetFrame() )->m_pImpl->m_bAlreadyQueued = false;
1162  if ( false == SP_ACCESS( SP_ACCESS(( *iter ))->GetFrame() )->m_pImpl->m_bAlreadyAnnounced )
1163  {
1164  // Delete frame if it was not announced / was revoked before
1165  SP_ACCESS( SP_ACCESS(( *iter ))->GetFrame() )->m_pImpl->m_frame.context[FRAME_HDL] = NULL;
1166  // End write lock frame handler
1167  SP_ACCESS( tmpMutex )->Unlock();
1168  iter = m_pImpl->m_frameHandlers.Vector.erase( iter );
1169  }
1170  else
1171  {
1172  // End write lock frame handler
1173  SP_ACCESS( tmpMutex )->Unlock();
1174  ++iter;
1175  }
1176  }
1177  // End write lock frame handler list
1179  }
1180  else
1181  {
1182  LOG_FREE_TEXT( "Could not lock frame handler list." )
1183  }
1184  }
1185  else
1186  {
1187  LOG_FREE_TEXT( "Could not flush frame queue" )
1188  }
1189 
1190  return static_cast<VmbErrorType>( res );
1191 }
1192 
1194 {
1195  return static_cast<VmbErrorType>( VmbCaptureStart( GetHandle() ) );
1196 }
1197 
1199 {
1200  VmbError_t res = VmbCaptureEnd( GetHandle() );
1201 
1202  return static_cast<VmbErrorType>( res );
1203 }
1204 
1206 {
1207  try
1208  {
1209  FrameHandlerPtr pFH( new FrameHandler( rFrame, SP_ACCESS( rFrame )->m_pImpl->m_pObserver ));
1210  if( SP_ISNULL( pFH ) )
1211  {
1212  return VmbErrorResources;
1213  }
1214  SP_ACCESS( rFrame )->m_pImpl->m_frame.context[FRAME_HDL] = SP_ACCESS(pFH);
1215  m_frameHandlers.Vector.push_back( pFH );
1216  return VmbErrorSuccess;
1217  }
1218  catch(...)
1219  {
1220  return VmbErrorResources;
1221  }
1222 }
1223 
1224 //
1225 // Method: SaveCameraSettings()
1226 //
1227 // Purpose: Saves the current camera setup to an XML file
1228 //
1229 // Parameters:
1230 //
1231 // [in] pStrFileName xml file name
1232 // [in] pSettings pointer to settings struct
1233 //
1234 // Returns:
1235 //
1236 // - VmbErrorSuccess: If no error
1237 // - VmbErrorApiNotStarted: VmbStartup() was not called before the current command
1238 // - VmbErrorBadHandle: The given handle is not valid
1239 // - VmbErrorInternalFault: When something unexpected happens in VimbaC function
1240 // - VmbErrorOther: Every other failure in load/save settings implementation class
1241 //
1242 VmbErrorType Camera::SaveCameraSettings( const char * const pStrFileName, VmbFeaturePersistSettings_t *pSettings ) const
1243 {
1245 
1246 // parameter check
1247  if( NULL == pStrFileName )
1248  {
1249  return VmbErrorBadParameter;
1250  }
1251 
1252 // check internal settings struct variables
1253  VmbBool_t useInternalStruct = true;
1254  if( false == ((VmbFeaturePersistAll <= m_pImpl->m_persistType) && (VmbFeaturePersistNoLUT >= m_pImpl->m_persistType)) )
1255  {
1256  useInternalStruct = false;
1257  }
1258  if( false == ((0 < m_pImpl->m_maxIterations) && (10 > m_pImpl->m_maxIterations)) )
1259  {
1260  useInternalStruct = false;
1261  }
1262  if( false == ((0 < m_pImpl->m_loggingLevel) && (5 > m_pImpl->m_loggingLevel)) )
1263  {
1264  useInternalStruct = false;
1265  }
1266 
1267 // check if internal struct shall be used
1268  if( VmbBoolTrue == useInternalStruct )
1269  {
1270  VmbFeaturePersistSettings_t newSettings;
1271  newSettings.persistType = m_pImpl->m_persistType;
1272  newSettings.maxIterations = m_pImpl->m_maxIterations;
1273  newSettings.loggingLevel = m_pImpl->m_loggingLevel;
1274  err = (VmbErrorType)VmbCameraSettingsSave( GetHandle(), pStrFileName, &newSettings, sizeof(newSettings) );
1275  }
1276  else
1277  {
1278  if( NULL == pSettings )
1279  {
1280  err = (VmbErrorType)VmbCameraSettingsSave( GetHandle(), pStrFileName, NULL, 0 );
1281  }
1282  else
1283  {
1284  err = (VmbErrorType)VmbCameraSettingsSave( GetHandle(), pStrFileName, pSettings, sizeof(*pSettings) );
1285  }
1286  }
1287 
1288 
1289 
1290  return err;
1291 }
1292 
1293 //
1294 // Method: LoadCameraSettings()
1295 //
1296 // Purpose: Loads the current camera setup from an XML file into the camera
1297 //
1298 // Parameters:
1299 //
1300 // [in] pStrFileName xml file name
1301 // [in] pSettings pointer to settings struct
1302 //
1303 // Returns:
1304 //
1305 // - VmbErrorSuccess: If no error
1306 // - VmbErrorApiNotStarted: VmbStartup() was not called before the current command
1307 // - VmbErrorBadHandle: The given handle is not valid
1308 // - VmbErrorInternalFault: When something unexpected happens in VimbaC function
1309 // - VmbErrorOther: Every other failure in load/save settings implementation class
1310 //
1311 VmbErrorType Camera::LoadCameraSettings( const char * const pStrFileName, VmbFeaturePersistSettings_t *pSettings ) const
1312 {
1314 
1315 // parameter check
1316  if( NULL == pStrFileName )
1317  {
1318  return VmbErrorBadParameter;
1319  }
1320 
1321 // check internal settings struct variables
1322  VmbBool_t useInternalStruct = true;
1323  if( false == ((VmbFeaturePersistAll <= m_pImpl->m_persistType) && (VmbFeaturePersistNoLUT >= m_pImpl->m_persistType)) )
1324  {
1325  useInternalStruct = false;
1326  }
1327  if( false == ((0 < m_pImpl->m_maxIterations) && (10 > m_pImpl->m_maxIterations)) )
1328  {
1329  useInternalStruct = false;
1330  }
1331  if( false == ((0 < m_pImpl->m_loggingLevel) && (5 > m_pImpl->m_loggingLevel)) )
1332  {
1333  useInternalStruct = false;
1334  }
1335 
1336 // check if internal struct shall be used
1337  if( VmbBoolTrue == useInternalStruct )
1338  {
1339  VmbFeaturePersistSettings_t newSettings;
1340  newSettings.persistType = m_pImpl->m_persistType;
1341  newSettings.maxIterations = m_pImpl->m_maxIterations;
1342  newSettings.loggingLevel = m_pImpl->m_loggingLevel;
1343  err = (VmbErrorType)VmbCameraSettingsLoad( GetHandle(), pStrFileName, &newSettings, sizeof(newSettings) );
1344  }
1345  else
1346  {
1347  if( NULL == pSettings )
1348  {
1349  err = (VmbErrorType)VmbCameraSettingsLoad( GetHandle(), pStrFileName, NULL, 0 );
1350  }
1351  else
1352  {
1353  err = (VmbErrorType)VmbCameraSettingsLoad( GetHandle(), pStrFileName, pSettings, sizeof(*pSettings) );
1354  }
1355  }
1356 
1357  return err;
1358 }
1359 
1360 //
1361 // Method: LoadSaveSettingsSetup()
1362 //
1363 // Purpose: Sets Load/Save settings behaviour (alternative to settings struct)
1364 //
1365 // Parameters:
1366 //
1367 // [in] persistType determines which feature shall be considered during load/save settings
1368 // [in] maxIterations determines how many 'tries' during loading feature values shall be performed
1369 // [in] loggingLevel determines level of detail for load/save settings logging
1370 //
1371 void Camera::LoadSaveSettingsSetup( VmbFeaturePersist_t persistType, VmbUint32_t maxIterations, VmbUint32_t loggingLevel )
1372 {
1373  if( true == ((VmbFeaturePersistAll != persistType) && (VmbFeaturePersistStreamable != persistType) && (VmbFeaturePersistNoLUT != persistType)) )
1374  {
1376  }
1377  else
1378  {
1379  m_pImpl->m_persistType = persistType;
1380  }
1381 
1382  if( false == ((0 < maxIterations) && (6 > maxIterations)) )
1383  {
1384  m_pImpl->m_maxIterations = 5;
1385  }
1386  else
1387  {
1388  m_pImpl->m_maxIterations = maxIterations;
1389  }
1390 
1391  if( false == ((0 < loggingLevel) && (5 > loggingLevel)) )
1392  {
1393  m_pImpl->m_loggingLevel = 4;
1394  }
1395  else
1396  {
1397  m_pImpl->m_loggingLevel = loggingLevel;
1398  }
1399 }
1400 
1401 }} // namespace AVT::VmbAPI
VmbInt32_t VmbError_t
virtual IMEXPORT VmbErrorType Close()
Definition: Camera.cpp:559
virtual IMEXPORT ~Camera()
Definition: Camera.cpp:530
IMEXPORT VmbErrorType GetFeatureByName(const char *pName, FeaturePtr &pFeature)
IMEXPORT VmbErrorType AcquireSingleImage(FramePtr &pFrame, VmbUint32_t timeout)
Definition: Camera.cpp:754
bool EnterWriteLock(BasicLockable &rLockable, bool bExclusive=false)
#define SP_ISNULL(sp)
char VmbBool_t
std::vector< T > Vector
Definition: Helper.h:41
IMEXPORTC VmbError_t VMB_CALL VmbRegistersWrite(const VmbHandle_t handle, VmbUint32_t writeCount, const VmbUint64_t *pAddressArray, const VmbUint64_t *pDataArray, VmbUint32_t *pNumCompleteWrites)
IMEXPORTC VmbError_t VMB_CALL VmbCaptureFrameQueue(const VmbHandle_t cameraHandle, const VmbFrame_t *pFrame, VmbFrameCallback callback)
VmbUint32_t VmbAccessMode_t
Definition: VimbaC.h:131
long long VmbInt64_t
VmbUint32_t loggingLevel
Definition: VimbaC.h:312
ConditionHelper m_conditionHelper
Definition: Camera.cpp:473
#define SP_ACCESS(sp)
IMEXPORTC VmbError_t VMB_CALL VmbRegistersRead(const VmbHandle_t handle, VmbUint32_t readCount, const VmbUint64_t *pAddressArray, VmbUint64_t *pDataArray, VmbUint32_t *pNumCompleteReads)
VmbInterfaceType m_eInterfaceType
Definition: Camera.cpp:470
VmbInt32_t m_loggingLevel
Definition: Camera.cpp:480
IMEXPORTC VmbError_t VMB_CALL VmbMemoryRead(const VmbHandle_t handle, VmbUint64_t address, VmbUint32_t bufferSize, char *dataBuffer, VmbUint32_t *pSizeComplete)
IMEXPORTC VmbError_t VMB_CALL VmbCameraClose(const VmbHandle_t cameraHandle)
int VmbInt32_t
IMEXPORTC VmbError_t VMB_CALL VmbCaptureStart(const VmbHandle_t cameraHandle)
const AcquireImageHelper & operator=(const AcquireImageHelper &o)
virtual IMEXPORT VmbErrorType Open(VmbAccessModeType accessMode)
Definition: Camera.cpp:537
static VmbErrorType AnnounceFrames(Camera &Camera, FramePtrVector &Frames, VmbUint32_t nBufferCount, VmbInt64_t nPayloadSize, const IFrameObserverPtr &Observer)
Definition: Camera.cpp:243
VmbUint32_t maxIterations
Definition: VimbaC.h:311
VmbAccessMode_t permittedAccess
Definition: VimbaC.h:156
char const *const AVT_IP_OR_MAC_ADDRESS
Definition: Helper.h:51
static void VMB_CALL FrameDoneCallback(const VmbHandle_t handle, VmbFrame_t *pFrame)
struct AVT::VmbAPI::Camera::Impl::CameraInfo m_cameraInfo
virtual VmbErrorType ReadRegisters(const Uint64Vector &addresses, Uint64Vector &buffer) const
IMEXPORTC VmbError_t VMB_CALL VmbCaptureFrameWait(const VmbHandle_t cameraHandle, const VmbFrame_t *pFrame, VmbUint32_t timeout)
IMEXPORTC VmbError_t VMB_CALL VmbCameraSettingsSave(const VmbHandle_t handle, const char *fileName, VmbFeaturePersistSettings_t *pSettings, VmbUint32_t sizeofSettings)
void ExitWriteLock(BasicLockable &rLockable)
VmbInt32_t m_maxIterations
Definition: Camera.cpp:479
VmbErrorType
virtual VmbErrorType WriteMemory(const VmbUint64_t &address, const UcharVector &buffer)
VmbAccessModeType
Definition: VimbaC.h:123
VmbFeaturePersist_t persistType
Definition: VimbaC.h:310
VmbFeaturePersist_t m_persistType
Definition: Camera.cpp:478
#define LOG_FREE_TEXT(txt)
Definition: LoggerDefines.h:56
IMEXPORTC VmbError_t VMB_CALL VmbFrameRevokeAll(const VmbHandle_t cameraHandle)
unsigned char VmbUchar_t
void * VmbHandle_t
IMEXPORT void LoadSaveSettingsSetup(VmbFeaturePersist_t persistType, VmbUint32_t maxIterations, VmbUint32_t loggingLevel)
Definition: Camera.cpp:1371
VmbErrorType SaveCameraSettings(std::string fileName, VmbFeaturePersistSettings_t *pSettings=0) const
static VmbErrorType SetupFrame(FramePtr &pFrame, VmbInt64_t PayloadSize)
Definition: Camera.cpp:138
IMEXPORTC VmbError_t VMB_CALL VmbCameraInfoQuery(const char *idString, VmbCameraInfo_t *pInfo, VmbUint32_t sizeofCameraInfo)
Camera & operator=(const Camera &)
Definition: Camera.cpp:495
IMEXPORTC VmbError_t VMB_CALL VmbFrameAnnounce(const VmbHandle_t cameraHandle, const VmbFrame_t *pFrame, VmbUint32_t sizeofFrame)
LockableVector< FrameHandlerPtr > m_frameHandlers
Definition: Camera.cpp:472
IMEXPORT VmbErrorType GetPermittedAccess(VmbAccessModeType &permittedAccess) const
Definition: Camera.cpp:711
unsigned long long VmbUint64_t
std::vector< FramePtr > FramePtrVector
Definition: Frame.h:337
VmbErrorType AcquireMultipleImages(FramePtrVector &frames, VmbUint32_t timeout)
IMEXPORTC VmbError_t VMB_CALL VmbMemoryWrite(const VmbHandle_t handle, VmbUint64_t address, VmbUint32_t bufferSize, const char *dataBuffer, VmbUint32_t *pSizeComplete)
VmbErrorType Prepare(FramePtr &pFrame, VmbInt64_t PayloadSize)
Definition: Camera.cpp:300
IMEXPORT VmbErrorType FlushQueue()
Definition: Camera.cpp:1144
VmbErrorType GetModel(std::string &model) const
IMEXPORTC VmbError_t VMB_CALL VmbFrameRevoke(const VmbHandle_t cameraHandle, const VmbFrame_t *pFrame)
VmbErrorType LoadCameraSettings(std::string fileName, VmbFeaturePersistSettings_t *pSettings=0) const
#define SP_SET(sp, rawPtr)
VmbErrorType Prepare(FramePtr *pFrames, VmbUint32_t nFrameCount, VmbInt64_t nPayloadSize, VmbUint32_t &nFramesQueued)
Definition: Camera.cpp:353
#define SP_ISEQUAL(sp1, sp2)
IMEXPORT VmbErrorType QueueFrame(const FramePtr &pFrame)
Definition: Camera.cpp:1102
VmbInterfaceType
Definition: VimbaC.h:107
VmbFeaturePersist_t m_persistType
Definition: Camera.h:623
tear_down_tasks GetTask()
get the top most taks and pop it from stack
Definition: Camera.cpp:123
VmbUint32_t VmbFeaturePersist_t
Definition: VimbaC.h:303
static VmbErrorType AnnounceFrames(Camera &Camera, FramePtr *pFrames, VmbUint32_t nFrameCount, VmbInt64_t nPayloadSize, VmbUint32_t &nFramesAnnounced)
Definition: Camera.cpp:203
IMEXPORT VmbErrorType StopContinuousImageAcquisition()
Definition: Camera.cpp:926
virtual VmbErrorType ReadMemory(const VmbUint64_t &address, UcharVector &buffer) const
VmbErrorType AppendFrameToVector(const FramePtr &frame)
Definition: Camera.cpp:1205
std::vector< tear_down_tasks > task_storage
Definition: Camera.cpp:119
IMEXPORT VmbErrorType StartCapture()
Definition: Camera.cpp:1193
VmbErrorType RunFeatureCommand(Camera &cam, const char *name)
Definition: Camera.cpp:85
IMEXPORTC VmbError_t VMB_CALL VmbCameraSettingsLoad(const VmbHandle_t handle, const char *fileName, VmbFeaturePersistSettings_t *pSettings, VmbUint32_t sizeofSettings)
unsigned int VmbUint32_t
IMEXPORT VmbErrorType GetInterfaceType(VmbInterfaceType &interfaceType) const
Definition: Camera.cpp:704
IMEXPORT VmbErrorType RevokeFrame(const FramePtr &pFrame)
Definition: Camera.cpp:1012
VmbErrorType GetSerialNumber(std::string &serialNumber) const
virtual VmbErrorType WriteRegisters(const Uint64Vector &addresses, const Uint64Vector &buffer)
VmbErrorType GetName(std::string &name) const
IMEXPORT VmbErrorType StartContinuousImageAcquisition(int bufferCount, const IFrameObserverPtr &pObserver)
Definition: Camera.cpp:856
IMEXPORTC VmbError_t VMB_CALL VmbCameraOpen(const char *idString, VmbAccessMode_t accessMode, VmbHandle_t *pCameraHandle)
void SetHandle(const VmbHandle_t handle)
VmbErrorType GetFeatureValueInt(Camera &cam, const char *name, VmbInt64_t &val)
Definition: Camera.cpp:54
IMEXPORT VmbErrorType RevokeAllFrames()
Definition: Camera.cpp:1064
IMEXPORTC VmbError_t VMB_CALL VmbCaptureEnd(const VmbHandle_t cameraHandle)
VmbErrorType GetID(std::string &cameraID) const
VmbErrorType GetInterfaceID(std::string &interfaceID) const
IMEXPORT VmbErrorType EndCapture()
Definition: Camera.cpp:1198
IMEXPORTC VmbError_t VMB_CALL VmbCaptureQueueFlush(const VmbHandle_t cameraHandle)
IMEXPORT VmbErrorType AnnounceFrame(const FramePtr &pFrame)
Definition: Camera.cpp:970


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