CCheckboardCalibSupplierComp.h
Go to the documentation of this file.
1 #ifndef iipr_CCheckboardCalibSupplierComp_included
2 #define iipr_CCheckboardCalibSupplierComp_included
3 
4 
5 // ACF includes
9 #include <i2d/CLine2d.h>
10 #include <iimg/IBitmapProvider.h>
11 
12 // ACF-Solutions includes
13 #include <imeas/INumericValue.h>
15 #include <iproc/IProcessor.h>
19 
20 
21 namespace iipr
22 {
23 
24 
29  public iinsp::TSupplierCompWrap< icalib::CPerspectiveCalibration2d >,
30  virtual public i2d::ICalibrationProvider
31 {
32 public:
34 
35  I_BEGIN_COMPONENT(CCheckboardCalibSupplierComp);
36  I_REGISTER_INTERFACE(i2d::ICalibrationProvider);
37  I_REGISTER_SUBELEMENT(CheckboardParamContraints);
38  I_REGISTER_SUBELEMENT_INTERFACE(CheckboardParamContraints, imeas::INumericConstraints, ExtractCheckboardParamContraints);
39  I_REGISTER_SUBELEMENT_INTERFACE(CheckboardParamContraints, istd::IChangeable, ExtractCheckboardParamContraints);
40  I_ASSIGN(m_bitmapProviderCompPtr, "BitmapProvider", "Provide input image", true, "BitmapProvider");
41  I_ASSIGN_TO(m_bitmapProviderModelCompPtr, m_bitmapProviderCompPtr, false);
42  I_ASSIGN_TO(m_bitmapProviderSupplierCompPtr, m_bitmapProviderCompPtr, false);
43  I_ASSIGN(m_lineFinderCompPtr, "LineFinder", "Finder of lines on image", true, "LineFinder");
44  I_ASSIGN(m_checkboardParamsId, "CheckboardParamsId", "ID of checkboard parameters in parameter set (type imeas::INumericValue):\n1\t1. grid size\n\t2. cell size in logical units", false, "CheckboardParams");
45  I_ASSIGN(m_defaultCheckboardParamsCompPtr, "DefaultCheckboardParams", "Default parameter controlling size of single checkboard cell when it is not defined in parameter set:\n1\t1. grid size\n\t2. cell size in logical units", false, "DefaultCheckboardParams");
46  I_ASSIGN(m_axisXParamIdAttrPtr, "AxisXParamId", "ID of axis X template in parameter set (type i2d::CLine2d), it is used to coarse knowing direction of X axis", false, "AxisX");
47  I_ASSIGN(m_defaultAxisXParamCompPtr, "DefaultAxisXParam", "Default parameter controlling axis X template, it is used to coarse knowing direction of X axis", false, "DefaultAxisXParam");
48  I_ASSIGN(m_axisYParamIdAttrPtr, "AxisYParamId", "ID of axis Y template in parameter set (type i2d::CLine2d), it is used to coarse knowing direction of Y axis", false, "AxisY");
49  I_ASSIGN(m_defaultAxisYParamCompPtr, "DefaultAxisYParam", "Default parameter controlling axis Y template, it is used to coarse knowing direction of Y axis", false, "DefaultAxisYParam");
50  I_ASSIGN(m_distanceUnitInfoCompPtr, "DistanceUnitInfo", "Information about used distance units", false, "DistanceUnitInfo");
51  I_ASSIGN(m_defaultGridSizeAttrPtr, "DefaultGridSize", "Default size of grid if no checkboard parameters specified", true, 8);
52  I_ASSIGN(m_defaultCellSizeAttrPtr, "DefaultCellSize", "Default size of single cell (in logical units) if no checkboard parameters specified", true, 10);
53  I_END_COMPONENT;
54 
56 
57  // reimplemented (i2d::ICalibrationProvider)
58  virtual const i2d::ICalibration2d* GetCalibration() const;
59 
60 protected:
61  struct LineInfo
62  {
63  double weight;
65  };
66 
67  typedef QList<LineInfo> Lines;
68 
69  class LinesConsumer: virtual public iipr::IFeaturesConsumer
70  {
71  public:
72  // reimplemented (iipr::IFeaturesConsumer)
73  virtual void ResetFeatures();
74  virtual bool AddFeature(const imeas::INumericValue* featurePtr, bool* isFullPtr = NULL);
75 
77  };
78 
80  {
81  public:
83 
84  // reimplemented (imeas::INumericConstraints)
85  virtual const iprm::IOptionsList& GetValueListInfo() const;
86  virtual const imath::IUnitInfo* GetNumericValueUnitInfo(int index) const;
87 
88  protected:
89  // reimplemented (iprm::IOptionsList)
90  virtual int GetOptionsFlags() const;
91  virtual int GetOptionsCount() const;
92  virtual QString GetOptionName(int index) const;
93  virtual QString GetOptionDescription(int index) const;
94  virtual QByteArray GetOptionId(int index) const;
95  virtual bool IsOptionEnabled(int index) const;
96 
97  private:
98  imath::CGeneralUnitInfo m_cellSizeUnit;
99  const CCheckboardCalibSupplierComp* m_parentPtr;
100  };
101 
102  bool CalculateCalibration(const iimg::IBitmap& image, icalib::CPerspectiveCalibration2d& result) const;
103 
104  // reimplemented (iinsp::TSupplierCompWrap)
105  virtual int ProduceObject(ProductType& result) const;
106 
107  // reimplemented (icomp::CComponentBase)
108  virtual void OnComponentCreated();
109 
110 private:
111  I_REF(iimg::IBitmapProvider, m_bitmapProviderCompPtr);
112  I_REF(imod::IModel, m_bitmapProviderModelCompPtr);
113  I_REF(iinsp::ISupplier, m_bitmapProviderSupplierCompPtr);
114  I_REF(iipr::IImageToFeatureProcessor, m_lineFinderCompPtr);
115  I_ATTR(QByteArray, m_checkboardParamsId);
116  I_REF(imeas::INumericValue, m_defaultCheckboardParamsCompPtr);
117  I_ATTR(QByteArray, m_axisXParamIdAttrPtr);
118  I_REF(i2d::CLine2d, m_defaultAxisXParamCompPtr);
119  I_ATTR(QByteArray, m_axisYParamIdAttrPtr);
120  I_REF(i2d::CLine2d, m_defaultAxisYParamCompPtr);
121  I_REF(imath::IUnitInfo, m_distanceUnitInfoCompPtr);
122  I_ATTR(int, m_defaultGridSizeAttrPtr);
123  I_ATTR(double, m_defaultCellSizeAttrPtr);
124 
125  // static template methods for subelement access
126  template <class InterfaceType>
127  static InterfaceType* ExtractCheckboardParamContraints(CCheckboardCalibSupplierComp& component)
128  {
129  return &component.m_checkboardParamContraints;
130  }
131 
132  ChessboardParamsContraints m_checkboardParamContraints;
133 
134  static imath::CFixedPointManip s_gridSizeValueManip;
135  static imath::CGeneralUnitInfo s_gridSizeUnit;
136 };
137 
138 
139 } // namespace iipr
140 
141 
142 #endif // !iipr_CCheckboardCalibSupplierComp_included
143 
144 
iinsp::TSupplierCompWrap< icalib::CPerspectiveCalibration2d > BaseClass
virtual const imath::IUnitInfo * GetNumericValueUnitInfo(int index) const
Get range of possible numeric values for specified list index.
virtual const iprm::IOptionsList & GetValueListInfo() const
Get general information about the "content" of the numeric value.
ChessboardParamsContraints(const CCheckboardCalibSupplierComp *supplierPtr)
bool CalculateCalibration(const iimg::IBitmap &image, icalib::CPerspectiveCalibration2d &result) const
Standard implementation of interface iinsp::ISupplier with preparation for component implementation...
Supplier of bitmap built on difference of two images.
Describe additional meta information for set of numeric values.
virtual int ProduceObject(ProductType &result) const
Produce single object.
Allow to extract some features from the image.
virtual void ResetFeatures()
Remove all features from this container.
General parameter set containing list of numeric values.
Definition: INumericValue.h:20
#define NULL
Common interface for a features container consuming feature objects.
Base interface for suppliers providing calculating of objects on demand ("pull data" model)...
Definition: ISupplier.h:22
virtual bool AddFeature(const imeas::INumericValue *featurePtr, bool *isFullPtr=NULL)
Add new feature to the set of features.
virtual const i2d::ICalibration2d * GetCalibration() const

© 2007-2017 Witold Gantzke and Kirill Lepskiy