CSimpleCameraComp.h
Go to the documentation of this file.
1 #ifndef idc1394_CSimpleCameraComp_included
2 #define idc1394_CSimpleCameraComp_included
3 
4 
5 // DC1394 includes
6 #include <dc1394/dc1394.h>
7 
8 // ACF includes
9 #include "i2d/CRectangle.h"
10 #include "ilog/TLoggerCompWrap.h"
11 #include "icomp/CComponentBase.h"
12 
13 // ACF-Solutions includes
17 #include "icam/IExposureParams.h"
20 
21 
22 namespace idc1394
23 {
24 
25 
31  virtual public iproc::TSyncProcessorWrap<icam::IBitmapAcquisition>
32 {
33 public:
35 
36  I_BEGIN_COMPONENT(CSimpleCameraComp);
37  I_REGISTER_INTERFACE(icam::IBitmapAcquisition);
38  I_REGISTER_SUBELEMENT(AdjustConstraints);
39  I_REGISTER_SUBELEMENT_INTERFACE_T(AdjustConstraints, imeas::ILinearAdjustConstraints, ExtractAdjustContraints);
40  I_REGISTER_SUBELEMENT_INTERFACE_T(AdjustConstraints, istd::IChangeable, ExtractAdjustContraints);
41  I_REGISTER_SUBELEMENT(ExposureConstraints);
42  I_REGISTER_SUBELEMENT_INTERFACE_T(ExposureConstraints, icam::IExposureConstraints, ExtractExposureContraints);
43  I_REGISTER_SUBELEMENT_INTERFACE_T(ExposureConstraints, istd::IChangeable, ExtractExposureContraints);
44  I_ASSIGN(m_adjustParamsIdAttrPtr, "AdjustParamsId", "ID used to get brightness and contrast adjust parameters from the parameter set", false, "AdjustParams");
45  I_ASSIGN(m_defaultAdjustParamsCompPtr, "DefaultAdjustParams", "Default contrast and brightness adjust parameters that will be used", false, "DefaultAdjustParams");
46  I_ASSIGN(m_exposureParamsIdAttrPtr, "ExposureParamsId", "ID used to exposure parameters from the parameter set", false, "ExposureParams");
47  I_ASSIGN(m_defaultExposureParamsCompPtr, "DefaultExposureParams", "Default exposure parameters that will be used", false, "DefaultExposureParams");
48  I_ASSIGN(m_only8BitDepthAttrPtr, "Only8Bit", "Only modes with 8 bits will be accepted", true, true);
49  I_ASSIGN(m_bufferSizeAttrPtr, "BufferSize", "Number of frames in camera buffer", true, 1);
50  I_ASSIGN(m_waitTimeoutAttrPtr, "WaitTimeout", "Wait timeout for capture, if not set only frames currently acquired will be taken", false, 1);
51  I_END_COMPONENT;
52 
53  enum MessageId
54  {
57  };
58 
60 
61  // reimplemented (iproc::TSyncProcessorWrap<icam::IBitmapAcquisition>)
62  virtual int DoProcessing(
63  const iprm::IParamsSet* paramsPtr,
64  const istd::IPolymorphic* inputPtr,
65  istd::IChangeable* outputPtr,
66  ibase::IProgressManager* progressManagerPtr = NULL);
67 
68  // reimplemented (icam::IBitmapAcquisition)
69  virtual istd::CIndex2d GetBitmapSize(const iprm::IParamsSet* paramsPtr) const;
70 
71  // reimplemented (iproc::IProcessor)
72  virtual void InitProcessor(const iprm::IParamsSet* paramsPtr);
73 
74 protected:
78  void SetParametersToCamera(const iprm::IParamsSet* paramsPtr);
79 
80  bool GetAbsoluteFeatureRange(dc1394camera_t& camera, dc1394feature_t feature, istd::CRange& range) const;
81  bool SetAbsoluteFeatureValue(dc1394camera_t& camera, dc1394feature_t feature, double value);
82 
83  // reimplemented (icomp::CComponentBase)
84  virtual void OnComponentCreated();
85  virtual void OnComponentDestroyed();
86 
87 private:
88  class AdjustConstraints: public imeas::ILinearAdjustConstraints
89  {
90  public:
91  // reimplemented (imeas::ILinearAdjustConstraints)
92  virtual istd::CRange GetScaleFactorRange() const;
93  virtual istd::CRange GetOffsetFactorRange() const;
94 
95  istd::CRange scaleRange;
96  istd::CRange offsetRange;
97  };
98 
99  class ExposureConstraints: public icam::IExposureConstraints
100  {
101  public:
102  // reimplemented (icam::IExposureConstraints)
103  virtual istd::CRange GetShutterTimeRange() const;
104  virtual istd::CRange GetDelayTimeRange() const;
105  virtual istd::CRange GetEenDelayRange() const;
106 
107  istd::CRange shutterTimeRange;
108  };
109 
110  I_ATTR(QByteArray, m_adjustParamsIdAttrPtr);
111  I_REF(imeas::ILinearAdjustParams, m_defaultAdjustParamsCompPtr);
112  I_ATTR(QByteArray, m_exposureParamsIdAttrPtr);
113  I_REF(icam::IExposureParams, m_defaultExposureParamsCompPtr);
114  I_ATTR(bool, m_only8BitDepthAttrPtr);
115  I_ATTR(int, m_bufferSizeAttrPtr);
116  I_ATTR(double, m_waitTimeoutAttrPtr);
117  dc1394_t* m_libraryPtr;
118  dc1394camera_t* m_cameraPtr;
119 
120  AdjustConstraints m_adjustConstraints;
121  ExposureConstraints m_exposureConstraints;
122 
123  // static template methods for subelement access
124  template <class InterfaceType>
125  static InterfaceType* ExtractAdjustContraints(CSimpleCameraComp& component)
126  {
127  return &component.m_adjustConstraints;
128  }
129 
130  // static template methods for subelement access
131  template <class InterfaceType>
132  static InterfaceType* ExtractExposureContraints(CSimpleCameraComp& component)
133  {
134  return &component.m_exposureConstraints;
135  }
136 };
137 
138 
139 } // namespace idc1394
140 
141 
142 #endif // !idc1394_CSimpleCameraComp_included
143 
144 
virtual void OnComponentDestroyed()
void SetParametersToCamera(const iprm::IParamsSet *paramsPtr)
Set parameters from parameter set to camera.
ilog::CLoggerComponentBase BaseClass
I_REGISTER_SUBELEMENT(AdjustConstraints)
virtual int DoProcessing(const iprm::IParamsSet *paramsPtr, const istd::IPolymorphic *inputPtr, istd::IChangeable *outputPtr, ibase::IProgressManager *progressManagerPtr=NULL)
bool SetAbsoluteFeatureValue(dc1394camera_t &camera, dc1394feature_t feature, double value)
Simple fire wire camera implementation based on library libDC1394.
virtual void OnComponentCreated()
bool GetAbsoluteFeatureRange(dc1394camera_t &camera, dc1394feature_t feature, istd::CRange &range) const
virtual void InitProcessor(const iprm::IParamsSet *paramsPtr)
virtual istd::CIndex2d GetBitmapSize(const iprm::IParamsSet *paramsPtr) const
I_REGISTER_SUBELEMENT_INTERFACE_T(AdjustConstraints, imeas::ILinearAdjustConstraints, ExtractAdjustContraints)

© 2007-2011 Witold Gantzke and Kirill Lepskiy