Image Component Library (ICL)
CornerDetectorCSS.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 : ICLCV/src/ICLCV/CornerDetectorCSS.h **
10 ** Module : ICLCV **
11 ** Authors: Erik Weitnauer **
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 
33 #include <ICLUtils/CompatMacros.h>
34 #include <ICLUtils/Point32f.h>
35 #include <ICLUtils/Configurable.h>
36 #include <ICLCore/Types.h>
37 #include <vector>
38 #include <ICLUtils/Uncopyable.h>
39 
40 namespace icl{
41  namespace cv{
42 
44 
90  public:
93  std::vector<icl32f> gau;
94  float sigma;
95  float cutoff;
96  int width; // only one side of the gaussian, gau has width*2+1 elements!
97  GaussianKernel(): sigma(0), cutoff(0), width(0) {}
98  };
99 
101  CornerDetectorCSS(float angle_thresh=162.,
102  float rc_coeff=1.5,
103  float sigma=3.,
104  float curvature_cutoff=100.,
105  float straight_line_thresh=0.1,
106  bool accurate = false);
107 
110 
112  virtual void setPropertyValue(const std::string &propertyName,
113  const utils::Any &value);
114 
116  virtual std::vector<std::string> getPropertyList() const;
117 
119  virtual std::string getPropertyType(const std::string &propertyName) const;
120 
122  virtual std::string getPropertyInfo(const std::string &propertyName) const;
123 
125  virtual utils::Any getPropertyValue(const std::string &propertyName) const;
126 
128  virtual inline int getPropertyVolatileness(const std::string &propertyName) const { return 0; }
129 
131  virtual std::string getPropertyToolTip(const std::string &propertyName) const;
132 
134 
140  static int gaussian(GaussianKernel &gauss, float sigma, float cutoff);
141 
143 
154  template<class T> ICLCV_API
155  const std::vector<std::vector<utils::Point32f> > &detectCorners(const std::vector<std::vector<T> > &boundaries, const std::vector<icl32f> &sigmas);
156  template<class T> ICLCV_API
157  const std::vector<utils::Point32f> &detectCorners(const std::vector<T> &boundary);
158 
160 
161  inline const std::vector<utils::Point32f> &getLastCorners() const {
162  return corners;
163  }
164 
165  inline void setAngleThreshold(float value){ angle_thresh = value; }
166  inline void setRCCoeff(float value){ rc_coeff = value; }
167  inline void setSigma(float value){ sigma = value; }
168  inline void setCurvatureCutoff(float value){ curvature_cutoff = value; }
169  inline void setStraightLineThreshold(float value) { straight_line_thresh = value; }
170  inline void setAccurate(bool value) { accurate = value; }
171 
172  inline float getAngleThreshold() const { return angle_thresh;}
173  inline float getRCCoeff() const { return rc_coeff; }
174  inline float getSigma() const { return sigma; }
175  inline float getCurvatureCutoff() const { return curvature_cutoff; }
176  inline float getStraightLineThreshold() const { return straight_line_thresh;}
177  inline bool getAccurate() const { return accurate; }
178 
180 
196  static void convolute_1D(float *vec, int dim, float *kernel, int kernelDim, float *dst);
197 
198  private:
200  float angle_thresh, rc_coeff, sigma, curvature_cutoff, straight_line_thresh;
202  bool accurate;
203 
204  int gauss_radius(float sigma, float cutoff);
205  void fill_gauss(float *mask, float sigma, int width);
206  void convolute(const float *data, int data_length, const float *mask , int mask_length, float *convoluted);
207  void calculate_curvatures(const float *smoothed_x, const float *smoothed_y, int length, float curvature_cutoff, float *curvatures);
208  void calculate_curvatures_bulk(int array_length, int num_boundaries, const int *lengths,
209  const int *indices, const int *indices_padded, const float *smoothed_x, const float *smoothed_y, float curvature_cutoff, float *curvature);
210  int findExtrema(int *extrema, int *num_extrema_out, float* k, int length);
211  void removeRoundCorners(float rc_coeff, int maxima_offset, float* k, int length, int *extrema, int num_extrema, int *new_extrema, int *num_new_extrema_out);
212  void removeRoundCornersAccurate(float rc_coeff, int maxima_offset, float* k, int length, int *extrema, int num_extrema, int *extrema_out, int *num_extrema_out);
213  float cornerAngle(float *x, float *y, int prev, int current, int next, int length, float straight_line_thresh);
214  float cornerAngleAccurate(float *x, float *y, int prev, int current, int next, int array_length, float straight_line_thresh);
215  void removeFalseCorners(float angle_thresh, float* x, float* y, float* k, int length, int *maxima, int num_maxima, int *maxima_out, int *num_maxima_out);
216 
217  // result lists
218  std::vector<utils::Point32f> corners;
219  std::vector<std::vector<utils::Point32f> > corners_list;
220 
221  struct CLCurvature;
222  CLCurvature *clcurvature;
223  bool useOpenCL; // in case of no support, this is always false
224  };
225  } // namespace core
226 }
227 
void setAngleThreshold(float value)
Definition: CornerDetectorCSS.h:165
bool accurate
use acurate corner detection
Definition: CornerDetectorCSS.h:202
std::vector< utils::Point32f > corners
Definition: CornerDetectorCSS.h:218
undocument this line if you encounter any issues!
Definition: Any.h:37
Class interface for un-copyable classes.
Definition: Uncopyable.h:64
GaussianKernel()
Definition: CornerDetectorCSS.h:97
CLCurvature * clcurvature
Definition: CornerDetectorCSS.h:221
int width
Definition: CornerDetectorCSS.h:96
void setCurvatureCutoff(float value)
Definition: CornerDetectorCSS.h:168
float getAngleThreshold() const
Definition: CornerDetectorCSS.h:172
Curvature Corner Detector.
Definition: CornerDetectorCSS.h:89
float getSigma() const
Definition: CornerDetectorCSS.h:174
void setStraightLineThreshold(float value)
Definition: CornerDetectorCSS.h:169
void setRCCoeff(float value)
Definition: CornerDetectorCSS.h:166
void setAccurate(bool value)
Definition: CornerDetectorCSS.h:170
std::vector< icl32f > gau
Definition: CornerDetectorCSS.h:93
bool getAccurate() const
Definition: CornerDetectorCSS.h:177
ICLQt_API ImgROI data(ImgQ &r)
creates full ROI ROI-struct
#define ICLCV_API
Definition: CompatMacros.h:177
const std::vector< utils::Point32f > & getLastCorners() const
returns the result of last detectCorners call
Definition: CornerDetectorCSS.h:161
float getCurvatureCutoff() const
Definition: CornerDetectorCSS.h:175
float cutoff
Definition: CornerDetectorCSS.h:95
bool useOpenCL
Definition: CornerDetectorCSS.h:223
float straight_line_thresh
Definition: CornerDetectorCSS.h:200
float sigma
Definition: CornerDetectorCSS.h:94
virtual int getPropertyVolatileness(const std::string &propertyName) const
returns volatileness for given property
Definition: CornerDetectorCSS.h:128
Interface for classes that can be configured from configuration-files and GUI-Components.
Definition: Configurable.h:194
std::vector< std::vector< utils::Point32f > > corners_list
Definition: CornerDetectorCSS.h:219
float getRCCoeff() const
Definition: CornerDetectorCSS.h:173
1 dim gaussian kernel
Definition: CornerDetectorCSS.h:92
void setSigma(float value)
Definition: CornerDetectorCSS.h:167
Simple generic data type implementation that uses a string based data representation.
Definition: Any.h:109
float getStraightLineThreshold() const
Definition: CornerDetectorCSS.h:176