AcquireContinuousConfiguration.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 free-running continuous acquisition.
  10. This instant camera configuration is provided as header-only file. The code
  11. can be copied and modified for creating own configuration classes.
  12. */
  13. #ifndef INCLUDED_ACQUIRECONTINUOUSCONFIGURATION_H_7346765
  14. #define INCLUDED_ACQUIRECONTINUOUSCONFIGURATION_H_7346765
  15. #include <pylon/Platform.h>
  16. #ifdef _MSC_VER
  17. # pragma pack(push, PYLON_PACKING)
  18. #endif /* _MSC_VER */
  19. #include <pylon/InstantCamera.h>
  20. #include <pylon/ParameterIncludes.h>
  21. #include <pylon/ConfigurationHelper.h>
  22. namespace Pylon
  23. {
  24. /** \addtogroup Pylon_InstantCameraApiGeneric
  25. * @{
  26. */
  27. /*!
  28. \class CAcquireContinuousConfiguration
  29. \brief Changes the configuration of the camera to free-running continuous acquisition.
  30. The \c CAcquireContinuousConfiguration is the default configuration of the Instant Camera class.
  31. The CAcquireContinuousConfiguration is automatically registered when an Instant Camera object is created.
  32. This instant camera configuration is provided as header-only file. The code
  33. can be copied and modified for creating own configuration classes.
  34. */
  35. class CAcquireContinuousConfiguration : public CConfigurationEventHandler
  36. {
  37. public:
  38. /// Destructor
  39. virtual ~CAcquireContinuousConfiguration()
  40. {
  41. }
  42. /// Apply acquire continuous configuration.
  43. static void ApplyConfiguration( GenApi::INodeMap& nodemap )
  44. {
  45. using namespace GenApi;
  46. //Disable all trigger types.
  47. CConfigurationHelper::DisableAllTriggers( nodemap );
  48. //Disable compression mode.
  49. CConfigurationHelper::DisableCompression( nodemap );
  50. //Disable GenDC streaming.
  51. CConfigurationHelper::DisableGenDC( nodemap );
  52. // Set image component.
  53. CConfigurationHelper::SelectRangeComponent( nodemap );
  54. //Set acquisition mode.
  55. CEnumParameter( nodemap, "AcquisitionMode" ).SetValue( "Continuous" );
  56. }
  57. //Set basic camera settings.
  58. virtual void OnOpened( CInstantCamera& camera )
  59. {
  60. try
  61. {
  62. ApplyConfiguration( camera.GetNodeMap() );
  63. // Probe max packet size
  64. CConfigurationHelper::ProbePacketSize( camera.GetStreamGrabberNodeMap() );
  65. }
  66. catch (const GenericException& e)
  67. {
  68. throw RUNTIME_EXCEPTION( "Could not apply configuration. Pylon::GenericException caught in OnOpened method msg=%hs", e.what() );
  69. }
  70. catch (const std::exception& e)
  71. {
  72. throw RUNTIME_EXCEPTION( "Could not apply configuration. std::exception caught in OnOpened method msg=%hs", e.what() );
  73. }
  74. catch (...)
  75. {
  76. throw RUNTIME_EXCEPTION( "Could not apply configuration. Unknown exception caught in OnOpened method." );
  77. }
  78. }
  79. };
  80. /**
  81. * @}
  82. */
  83. }
  84. #ifdef _MSC_VER
  85. # pragma pack(pop)
  86. #endif /* _MSC_VER */
  87. #endif /* INCLUDED_ACQUIRECONTINUOUSCONFIGURATION_H_7346765 */