Image Component Library (ICL)
AdvancedMarkerGridDetector.h
Go to the documentation of this file.
1 /********************************************************************
2 ** Image Component Library (ICL) **
3 ** **
4 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld **
5 ** Neuroinformatics Group **
6 ** Website: www.iclcv.org and **
7 ** http://opensource.cit-ec.de/projects/icl **
8 ** **
9 ** File : ICLMarkers/src/ICLMarkers/AdvancedMarkerGridDetector.h **
10 ** Module : ICLMarkers **
11 ** Authors: Christof Elbrechter **
12 ** **
13 ** **
14 ** GNU LESSER GENERAL PUBLIC LICENSE **
15 ** This file may be used under the terms of the GNU Lesser General **
16 ** Public License version 3.0 as published by the **
17 ** **
18 ** Free Software Foundation and appearing in the file LICENSE.LGPL **
19 ** included in the packaging of this file. Please review the **
20 ** following information to ensure the license requirements will **
21 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt **
22 ** **
23 ** The development of this software was supported by the **
24 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. **
25 ** The Excellence Cluster EXC 277 is a grant of the Deutsche **
26 ** Forschungsgemeinschaft (DFG) in the context of the German **
27 ** Excellence Initiative. **
28 ** **
29 ********************************************************************/
30 
31 #pragma once
32 
34 #include <ICLUtils/Array2D.h>
35 #include <ICLUtils/ParamList.h>
37 #include <ICLMarkers/Fiducial.h>
38 
39 namespace icl{
40  namespace markers{
41 
44  public:
46 
49 
51 
54 
55  public:
56  // empty constructor
58 
60  AdvancedGridDefinition(const utils::Size &numCells,
61  const utils::Size32f &markerBounds,
62  const utils::Size32f &gridBounds,
63  const std::vector<int> &markerIDs=std::vector<int>(),
64  const std::string &markerType="bch") ;
65 
68  return markerBounds;
69  }
71  const utils::Size32f &getGridBounds() const {
72  return gridBounds;
73  }
74 
76  utils::Rect32f getBounds(int x, int y) const;
77 
78  };
79 
82  int id;
83  bool found;
84  public:
85 
93 
95  void setup(const utils::Point32f corners[4], const utils::Point32f &center);
96 
97  // internally used function that concatenates all points
98  std::vector<utils::Point32f> data() const;
99 
100  // internally used function that concatenates all points (without the center point)
101  std::vector<utils::Point32f> corners() const;
102 
104  void appendCornersTo(std::vector<utils::Point32f> &dst) const;
105 
106  };
107 
108  private:
113 
114  public:
116  Marker();
117 
119  Marker(int id, const utils::Point32f gridPoints[4], const utils::Point32f &center);
120 
122  void setImagePoints(const utils::Point32f corners[4],
123  const utils::Point32f &center=utils::Point32f::null);
124 
126  inline bool operator<(const Marker &m) const { return id < m.id; }
127 
129  void setFound(bool found){
130  this->found = found;
131  }
132 
133  bool wasFound() const {
134  return found;
135  }
136 
138  const KeyPoints &getImagePoints() const{
139  return imagePts;
140  }
142  const KeyPoints &getGridPoints() const {
143  return gridPts;
144  }
145 
148  return imagePts;
149  }
150 
151 
153  void visTo(utils::VisualizationDescription &vd) const;
154 
156  void getImagePointsTo(utils::Point32f *dst) const;
157 
159  template<class Transform>
160  inline void transformImagePointsTo(Marker &dst, Transform t) const{
161  dst.imagePts.ur = t(imagePts.ur);
162  dst.imagePts.lr = t(imagePts.lr);
163  dst.imagePts.ll = t(imagePts.ll);
164  dst.imagePts.ul = t(imagePts.ul);
165  dst.imagePts.center = t(imagePts.center);
166  }
167  };
168 
170  class ICLMarkers_API MarkerGrid : public utils::Array2D<Marker>{
173 
174  public:
176  MarkerGrid();
177 
180 
182  void init(const AdvancedGridDefinition &def);
183 
185  void update(const MarkerGridDetector::Result &r);
186 
189  return gridDef;
190  }
191 
193  const Marker &getMarker(int id) const ;
194 
197 
199  template<class Transform>
200  inline void transformImagePointsTo(MarkerGrid &dst, Transform t) const{
201  if(getSize() != dst.getSize()){
202  dst = MarkerGrid(gridDef);
203  }
204  for(int i=0;i<getDim();++i){
205  operator[](i).transformImagePointsTo(dst[i],t);
206  }
207  }
208  };
209 
212 
214  AdvancedMarkerGridDetector(const AdvancedGridDefinition &def);
215 
217  void init(const AdvancedGridDefinition &def);
218 
220  const MarkerGrid &detect(const core::ImgBase *image);
221 
223  const MarkerGrid *getMarkerGrid() const { return &grid; }
224 
225  private:
227  };
228  }
229 }
Utility class that allows a regular grid of fiducial markers to be tracked.
Definition: MarkerGridDetector.h:45
undocument this line if you encounter any issues!
Definition: Any.h:37
const Size & getSize() const
returns the matrix size
Definition: Array2D.h:163
utils::Point32f lr
upper left point
Definition: AdvancedMarkerGridDetector.h:89
AdvancedGridDefinition gridDef
internal metrics
Definition: AdvancedMarkerGridDetector.h:172
const utils::Size32f & getGridBounds() const
returns internal grid-bounds value
Definition: AdvancedMarkerGridDetector.h:71
internal key-point structure
Definition: AdvancedMarkerGridDetector.h:87
const utils::Size32f & getMarkerBounds() const
returns internal marker-bounds value
Definition: AdvancedMarkerGridDetector.h:67
const MarkerGrid * getMarkerGrid() const
returns the internal marker grid
Definition: AdvancedMarkerGridDetector.h:223
Marker Grid geometry definition type.
Definition: MarkerGridDetector.h:59
void setFound(bool found)
sets the 'found' flag
Definition: AdvancedMarkerGridDetector.h:129
Floating point precision implementation of the Rect class.
Definition: Rect32f.h:45
ICLQt_API ImgROI data(ImgQ &r)
creates full ROI ROI-struct
utils::Size32f gridBounds
size of the whole grid
Definition: AdvancedMarkerGridDetector.h:53
const KeyPoints & getGridPoints() const
returns static grid points
Definition: AdvancedMarkerGridDetector.h:142
static const Point32f null
null Point is x=0, y=0
Definition: Point32f.h:51
Size class of the ICL.
Definition: Size.h:61
utils::Point32f ll
lower left point
Definition: AdvancedMarkerGridDetector.h:90
bool operator<(const Marker &m) const
for sorting (is that needed)
Definition: AdvancedMarkerGridDetector.h:126
KeyPoints & getImagePoints()
returns current image points (unconst version)
Definition: AdvancedMarkerGridDetector.h:147
utils::Size32f markerBounds
size of a single marker in mm
Definition: AdvancedMarkerGridDetector.h:48
const KeyPoints & getImagePoints() const
returns current image points
Definition: AdvancedMarkerGridDetector.h:138
KeyPoints gridPts
internal key-points (in grid space, initialized at construction time)
Definition: AdvancedMarkerGridDetector.h:112
Abstract class for visualization tasks.
Definition: VisualizationDescription.h:73
MarkerGridDetector Super
Definition: AdvancedMarkerGridDetector.h:45
utils::Point32f ur
upper right point
Definition: AdvancedMarkerGridDetector.h:88
Single precission 3D Vectors Point class of the ICL.
Definition: Point32f.h:41
Extension of the MarkerGridDetector class that provides a more advanced output.
Definition: AdvancedMarkerGridDetector.h:43
Simple 2D-Array class that provides shallow copy per default.
Definition: Array2D.h:61
int id
marker id
Definition: AdvancedMarkerGridDetector.h:82
utils::Array2D< Marker > Super
convenience typedef
Definition: AdvancedMarkerGridDetector.h:171
KeyPoints imagePts
internal key-points (in image space, updated at runtime)
Definition: AdvancedMarkerGridDetector.h:110
void transformImagePointsTo(Marker &dst, Transform t) const
utility method that transforms the marker's image points ...
Definition: AdvancedMarkerGridDetector.h:160
internal data-class the represents a more sophisticated
Definition: AdvancedMarkerGridDetector.h:81
Size32f class of the ICL (float valued)
Definition: Size32f.h:40
bool wasFound() const
Definition: AdvancedMarkerGridDetector.h:133
utils::Point32f ul
upper left point
Definition: AdvancedMarkerGridDetector.h:91
Represents whole grid of markers.
Definition: AdvancedMarkerGridDetector.h:170
bool found
was it found
Definition: AdvancedMarkerGridDetector.h:83
#define ICLMarkers_API
Definition: CompatMacros.h:180
utils::Point32f center
center point
Definition: AdvancedMarkerGridDetector.h:92
const AdvancedGridDefinition & getGridDef() const
returns the internal grid definitiion
Definition: AdvancedMarkerGridDetector.h:188
ImgBase is the Image-Interface class that provides save access to underlying Img-template .
Definition: ImgBase.h:131
Definition: AdvancedMarkerGridDetector.h:47
MarkerGrid grid
internal marker grid
Definition: AdvancedMarkerGridDetector.h:226
void transformImagePointsTo(MarkerGrid &dst, Transform t) const
transforms all markers using a transformation function
Definition: AdvancedMarkerGridDetector.h:200
AdvancedGridDefinition()
Definition: AdvancedMarkerGridDetector.h:57