CCircleFindProcessorComp.h
Go to the documentation of this file.
1 #ifndef iipr_CCircleFindProcessorComp_included
2 #define iipr_CCircleFindProcessorComp_included
3 
4 
5 // ACF includes
7 #include "i2d/CCircle.h"
8 #include "i2d/CAnnulus.h"
9 #include "i2d/CPolypoint.h"
11 #include "icomp/CComponentBase.h"
13 
19 
20 
21 namespace iipr
22 {
23 
24 
32  public icomp::CComponentBase,
33  public iproc::TSyncProcessorWrap<IImageToFeatureProcessor>
34 {
35 public:
37 
38  enum MessageId
39  {
40  MI_INTERMEDIATE = 0x26723
41  };
42 
43  I_BEGIN_COMPONENT(CCircleFindProcessorComp);
44  I_REGISTER_INTERFACE(IImageToFeatureProcessor);
45  I_REGISTER_INTERFACE(iproc::IProcessor);
46  I_ASSIGN(m_slaveProcessorCompPtr, "SlaveEdgeProcessor", "Slave edge finder processor converting image to list of found edges", true, "SlaveEdgeProcessor");
47  I_ASSIGN(m_featuresMapperCompPtr, "FeaturesMapper", "Calculate position from caliper extracted features", true, "FeaturesMapper");
48  I_ASSIGN(m_resultCalibrationCompPtr, "ResultCalibration", "Calibration should be used for result", false, "ResultCalibration");
49  I_ASSIGN(m_aoiParamIdAttrPtr, "AoiParamId", "ID of area of interest in parameter set", true, "AoiParams");
50  I_ASSIGN(m_circleFinderParamsIdAttrPtr, "CircleFinderParamsId", "ID cirlcie finder parameters in parameter set", true, "CircleFinderParams");
51  I_ASSIGN(m_slaveLineIdAttrPtr, "SlaveLineId", "ID of line parameter added by this processor to parameter set for slave edge processor", true, "LineParam");
52  I_ASSIGN(m_searchForAnnulusAttrPtr, "SearchForAnnulus", "If it is true, annulus will be searched", true, false);
53  I_ASSIGN(m_sendUsedPointsToTempAttrPtr, "SendUsedPointsToTemp", "If true, the used point positions will be send to temporary results", true, false);
54  I_ASSIGN(m_sendLinesToTempAttrPtr, "SendLinesToTemp", "If true, the caliper lines will be send to temporary results", true, false);
55  I_ASSIGN(m_tempConsumerCompPtr, "TempConsumer", "Consumer of temporary result messages", false, "TempResultsConsumer");
56  I_END_COMPONENT;
57 
59 
60  // reimplemented (iipr::IImageToFeatureProcessor)
61  virtual int DoExtractFeatures(
62  const iprm::IParamsSet* paramsPtr,
63  const iimg::IBitmap& image,
64  IFeaturesConsumer& results);
65 
66  // reimplemented (iproc::IProcessor)
67  virtual int DoProcessing(
68  const iprm::IParamsSet* paramsPtr,
69  const istd::IPolymorphic* inputPtr,
70  istd::IChangeable* outputPtr,
71  ibase::IProgressManager* progressManagerPtr = NULL);
72 
73 protected:
76 
77  struct Point
78  {
79  double weight;
81  };
82 
83  typedef QVector<Point> Points;
84 
85  struct Ray
86  {
87  Ray()
88  {
89  usedIndex = -1;
90  }
91 
93 
95  int usedIndex;
96  };
97 
98  typedef QVector<Ray> Rays;
99 
100  bool AddAoiToRays(
101  const istd::IChangeable& aoiObject,
102  const iprm::IParamsSet& params,
103  const iimg::IBitmap& image,
104  const iipr::ICircleFinderParams& circleFinderParams,
105  Rays& inRays,
106  Rays& outRays,
107  i2d::CLine2d& projectionLine,
108  i2d::CVector2d& center);
109  bool CalculateCircle(const i2d::CVector2d& center, bool removeOutliers, double minOutliersDistance, Rays& rays, CircleFeature& result);
110  bool CalculateAnnulus(const i2d::CVector2d& center, Rays& inRays, Rays& outRays, AnnulusFeature& result);
111 
113  const i2d::CLine2d& projectionLine,
114  const iprm::IParamsSet& params,
115  const imeas::INumericValueProvider& container,
116  Rays& inRays,
117  Rays& outRays);
118 
119  void AddIntermediateResults(Rays& outRays);
120 
121 private:
122  I_REF(iproc::IProcessor, m_slaveProcessorCompPtr);
123  I_REF(iipr::IFeatureToImageMapper, m_featuresMapperCompPtr);
124  I_REF(i2d::ICalibration2d, m_resultCalibrationCompPtr);
125  I_ATTR(QByteArray, m_aoiParamIdAttrPtr);
126  I_ATTR(QByteArray, m_slaveLineIdAttrPtr);
127  I_ATTR(QByteArray, m_circleFinderParamsIdAttrPtr);
128  I_ATTR(bool, m_searchForAnnulusAttrPtr);
129  I_ATTR(bool, m_sendUsedPointsToTempAttrPtr);
130  I_ATTR(bool, m_sendLinesToTempAttrPtr);
131  I_REF(ilog::IMessageConsumer, m_tempConsumerCompPtr);
132 };
133 
134 
135 } // namespace iipr
136 
137 
138 #endif // !iipr_CCircleFindProcessorComp_included
139 
140 
void AddIntermediateResults(Rays &outRays)
TWeightedFeatureWrap< i2d::CCircle > CircleFeature
virtual int DoExtractFeatures(const iprm::IParamsSet *paramsPtr, const iimg::IBitmap &image, IFeaturesConsumer &results)
Wrapper of iproc::IProcessor for simple synchrone processor implementations.
virtual int DoProcessing(const iprm::IParamsSet *paramsPtr, const istd::IPolymorphic *inputPtr, istd::IChangeable *outputPtr, ibase::IProgressManager *progressManagerPtr=NULL)
bool CalculateAnnulus(const i2d::CVector2d &center, Rays &inRays, Rays &outRays, AnnulusFeature &result)
void AddProjectionResultsToRays(const i2d::CLine2d &projectionLine, const iprm::IParamsSet &params, const imeas::INumericValueProvider &container, Rays &inRays, Rays &outRays)
TWeightedFeatureWrap< i2d::CAnnulus > AnnulusFeature
bool AddAoiToRays(const istd::IChangeable &aoiObject, const iprm::IParamsSet &params, const iimg::IBitmap &image, const iipr::ICircleFinderParams &circleFinderParams, Rays &inRays, Rays &outRays, i2d::CLine2d &projectionLine, i2d::CVector2d &center)
Interface allowing mapping of extracted features to native coordinate systems.
Allow to extract some features from the image.
Provide access to the list of the numeric values.
Caliper based circle finder.
Interface for the circle finder parameter.
Common interface for a features container consuming feature objects.
Interface for all synchrone and assynchrone processors with "push data" model.
Definition: IProcessor.h:24
bool CalculateCircle(const i2d::CVector2d &center, bool removeOutliers, double minOutliersDistance, Rays &rays, CircleFeature &result)
Wrapper allowing to create feature object from some another serializable one.

© 2007-2011 Witold Gantzke and Kirill Lepskiy