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 
14 #include <iipr/IFeaturesProvider.h>
18 
19 
20 namespace iipr
21 {
22 
23 
30 class CCircleFindProcessorComp: public iproc::TSyncProcessorCompBase<IImageToFeatureProcessor>
31 {
32 public:
34 
35  I_BEGIN_COMPONENT(CCircleFindProcessorComp);
36  I_REGISTER_INTERFACE(IImageToFeatureProcessor);
37  I_REGISTER_INTERFACE(iproc::IProcessor);
38  I_ASSIGN(m_slaveProcessorCompPtr, "SlaveEdgeProcessor", "Slave edge finder processor converting image to list of found edges", true, "SlaveEdgeProcessor");
39  I_ASSIGN(m_featuresMapperCompPtr, "FeaturesMapper", "Calculate position from caliper extracted features", true, "FeaturesMapper");
40  I_ASSIGN(m_resultCalibrationCompPtr, "ResultCalibration", "Calibration should be used for result", false, "ResultCalibration");
41  I_ASSIGN(m_aoiParamIdAttrPtr, "AoiParamId", "ID of area of interest in parameter set", true, "AoiParams");
42  I_ASSIGN(m_circleFinderParamsIdAttrPtr, "CircleFinderParamsId", "ID cirlcie finder parameters in parameter set", true, "CircleFinderParams");
43  I_ASSIGN(m_slaveLineIdAttrPtr, "SlaveLineId", "ID of line parameter added by this processor to parameter set for slave edge processor", true, "LineParam");
44  I_ASSIGN(m_searchForAnnulusAttrPtr, "SearchForAnnulus", "If it is true, annulus will be searched", true, false);
45  I_ASSIGN(m_sendUsedPointsToTempAttrPtr, "SendUsedPointsToTemp", "If true, the used point positions will be send to temporary results", true, false);
46  I_ASSIGN(m_sendLinesToTempAttrPtr, "SendLinesToTemp", "If true, the caliper lines will be send to temporary results", true, false);
47  I_ASSIGN(m_resultConsumerCompPtr, "ResultConsumer", "Consumer of result messages with geometrical layout", false, "ResultConsumer");
48  I_ASSIGN(m_tempConsumerCompPtr, "TempConsumer", "Consumer of temporary result messages", false, "TempResultsConsumer");
49  I_END_COMPONENT;
50 
52 
53  // reimplemented (iipr::IImageToFeatureProcessor)
54  virtual int DoExtractFeatures(
55  const iprm::IParamsSet* paramsPtr,
56  const iimg::IBitmap& image,
57  IFeaturesConsumer& results,
58  ibase::IProgressManager* progressManagerPtr = NULL);
59 
60  // reimplemented (iproc::IProcessor)
61  virtual int DoProcessing(
62  const iprm::IParamsSet* paramsPtr,
63  const istd::IPolymorphic* inputPtr,
64  istd::IChangeable* outputPtr,
65  ibase::IProgressManager* progressManagerPtr = NULL);
66 
67 protected:
70 
71  struct Point
72  {
73  double weight;
75  bool wasChecked;
76  };
77 
78  typedef std::vector<Point> Points;
79 
80  struct Ray
81  {
82  Ray()
83  {
84  usedIndex = -1;
85  }
86 
88 
90  int usedIndex;
91  };
92 
93  typedef std::vector<Ray> Rays;
94 
95  bool AddAoiToRays(
96  const istd::IChangeable& aoiObject,
97  const iprm::IParamsSet& params,
98  const iimg::IBitmap& image,
99  const iipr::ICircleFinderParams& circleFinderParams,
100  Rays& inRays,
101  Rays& outRays,
102  i2d::CLine2d& projectionLine,
103  i2d::CVector2d& center,
104  int& totalRaysCount);
105  bool CalculateCircle(
106  const i2d::CVector2d& center,
107  bool removeOutliers,
108  double minOutliersDistance,
109  Rays& rays,
110  int totalRaysCount,
111  CircleFeature& result);
112  bool CalculateAnnulus(
113  const i2d::CVector2d& center,
114  Rays& inRays,
115  Rays& outRays,
116  int totalRaysCount,
117  AnnulusFeature& result);
118 
120  const i2d::CLine2d& projectionLine,
121  const iprm::IParamsSet& params,
122  const IFeaturesProvider& container,
123  Rays& inRays,
124  Rays& outRays);
125 
126  void AddIntermediateResults(Rays& outRays);
127 
128  // reimplemented (icomp::CComponentBase)
129  virtual void OnComponentCreated();
130 
131 private:
132  I_REF(iproc::IProcessor, m_slaveProcessorCompPtr);
133  I_REF(iipr::IFeatureToImageMapper, m_featuresMapperCompPtr);
134  I_REF(i2d::ICalibration2d, m_resultCalibrationCompPtr);
135  I_ATTR(QByteArray, m_aoiParamIdAttrPtr);
136  I_ATTR(QByteArray, m_slaveLineIdAttrPtr);
137  I_ATTR(QByteArray, m_circleFinderParamsIdAttrPtr);
138  I_ATTR(bool, m_searchForAnnulusAttrPtr);
139  I_ATTR(bool, m_sendUsedPointsToTempAttrPtr);
140  I_ATTR(bool, m_sendLinesToTempAttrPtr);
141  I_REF(ilog::IMessageConsumer, m_resultConsumerCompPtr);
142  I_REF(ilog::IMessageConsumer, m_tempConsumerCompPtr);
143 };
144 
145 
146 } // namespace iipr
147 
148 
149 #endif // !iipr_CCircleFindProcessorComp_included
150 
151 
void AddIntermediateResults(Rays &outRays)
TWeightedFeatureWrap< i2d::CCircle > CircleFeature
Simple definition macro for a synchronous processor.
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, int &totalRaysCount)
bool CalculateCircle(const i2d::CVector2d &center, bool removeOutliers, double minOutliersDistance, Rays &rays, int totalRaysCount, CircleFeature &result)
virtual int DoProcessing(const iprm::IParamsSet *paramsPtr, const istd::IPolymorphic *inputPtr, istd::IChangeable *outputPtr, ibase::IProgressManager *progressManagerPtr=NULL)
void AddProjectionResultsToRays(const i2d::CLine2d &projectionLine, const iprm::IParamsSet &params, const IFeaturesProvider &container, Rays &inRays, Rays &outRays)
virtual int DoExtractFeatures(const iprm::IParamsSet *paramsPtr, const iimg::IBitmap &image, IFeaturesConsumer &results, ibase::IProgressManager *progressManagerPtr=NULL)
TWeightedFeatureWrap< i2d::CAnnulus > AnnulusFeature
Interface allowing mapping of extracted features to native coordinate systems.
Container allowing access to features.
Allow to extract some features from the image.
Caliper based circle finder.
Interface for the circle finder parameter.
iproc::TSyncProcessorCompBase< IImageToFeatureProcessor > BaseClass
bool CalculateAnnulus(const i2d::CVector2d &center, Rays &inRays, Rays &outRays, int totalRaysCount, AnnulusFeature &result)
Common interface for a features container consuming feature objects.
Interface for all synchrone and asynchrone processors with "push data" model.
Definition: IProcessor.h:24
Wrapper allowing to create feature object from some another serializable one.

© 2007-2017 Witold Gantzke and Kirill Lepskiy