AcquireSingleFrameConfiguration.h 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. //-----------------------------------------------------------------------------
  2. // Basler pylon SDK
  3. // Copyright (c) 2010-2021 Basler AG
  4. // http://www.baslerweb.com
  5. // Author: Andreas Gau
  6. //-----------------------------------------------------------------------------
  7. /*!
  8. \file
  9. \brief An instant camera configuration for single frame acquisition.
  10. Use together with Pylon::CInstantCamera::GrabOne() only.
  11. This instant camera configuration is provided as header-only file. The code
  12. can be copied and modified for creating own configuration classes.
  13. */
  14. #ifndef INCLUDED_ACQUIRESINGLEFRAMECONFIGURATION_H_6529309
  15. #define INCLUDED_ACQUIRESINGLEFRAMECONFIGURATION_H_6529309
  16. #include <pylon/Platform.h>
  17. #ifdef _MSC_VER
  18. # pragma pack(push, PYLON_PACKING)
  19. #endif /* _MSC_VER */
  20. #include <pylon/InstantCamera.h>
  21. #include <pylon/ParameterIncludes.h>
  22. #include <pylon/ConfigurationHelper.h>
  23. namespace Pylon
  24. {
  25. /** \addtogroup Pylon_InstantCameraApiGeneric
  26. * @{
  27. */
  28. /*!
  29. \class CAcquireSingleFrameConfiguration
  30. \brief An instant camera configuration for single frame acquisition, Use together with CInstantCamera::GrabOne() only.
  31. The %CAcquireSingleFrameConfiguration is provided as header-only file.
  32. The code can be copied and modified for creating own configuration classes.
  33. \note Grabbing single images using Software Trigger (CSoftwareTriggerConfiguration) is recommended if you want to maximize frame rate.
  34. This is because the overhead per grabbed image is reduced compared to Single Frame Acquisition.
  35. The grabbing can be started using CInstantCamera::StartGrabbing().
  36. Images are grabbed using the CInstantCamera::WaitForFrameTriggerReady(), CInstantCamera::ExecuteSoftwareTrigger() and CInstantCamera::RetrieveResult() methods instead of using CInstantCamera::GrabOne().
  37. The grab can be stopped using CInstantCamera::StopGrabbing() when done.
  38. */
  39. class CAcquireSingleFrameConfiguration : public CConfigurationEventHandler
  40. {
  41. public:
  42. /// Destructor
  43. virtual ~CAcquireSingleFrameConfiguration()
  44. {
  45. }
  46. /// Apply acquire single frame configuration.
  47. static void ApplyConfiguration( GenApi::INodeMap& nodemap )
  48. {
  49. using namespace GenApi;
  50. //Disable all trigger types.
  51. CConfigurationHelper::DisableAllTriggers( nodemap );
  52. //Disable compression mode.
  53. CConfigurationHelper::DisableCompression( nodemap );
  54. //Disable GenDC streaming.
  55. CConfigurationHelper::DisableGenDC( nodemap );
  56. // Set image component.
  57. CConfigurationHelper::SelectRangeComponent( nodemap );
  58. //Set acquisition mode.
  59. CEnumParameter( nodemap, "AcquisitionMode" ).SetValue( "SingleFrame" );
  60. }
  61. //Set basic camera settings
  62. virtual void OnOpened( CInstantCamera& camera )
  63. {
  64. try
  65. {
  66. ApplyConfiguration( camera.GetNodeMap() );
  67. // Probe max packet size
  68. CConfigurationHelper::ProbePacketSize( camera.GetStreamGrabberNodeMap() );
  69. }
  70. catch (const GenericException& e)
  71. {
  72. throw RUNTIME_EXCEPTION( "Could not apply configuration. Pylon::GenericException caught in OnOpened method msg=%hs", e.what() );
  73. }
  74. catch (const std::exception& e)
  75. {
  76. throw RUNTIME_EXCEPTION( "Could not apply configuration. std::exception caught in OnOpened method msg=%hs", e.what() );
  77. }
  78. catch (...)
  79. {
  80. throw RUNTIME_EXCEPTION( "Could not apply configuration. Unknown exception caught in OnOpened method." );
  81. }
  82. }
  83. };
  84. /**
  85. * @}
  86. */
  87. }
  88. #ifdef _MSC_VER
  89. # pragma pack(pop)
  90. #endif /* _MSC_VER */
  91. #endif /* INCLUDED_ACQUIRESINGLEFRAMECONFIGURATION_H_6529309 */