Image Component Library (ICL)
|
00001 /******************************************************************** 00002 ** Image Component Library (ICL) ** 00003 ** ** 00004 ** Copyright (C) 2006-2013 CITEC, University of Bielefeld ** 00005 ** Neuroinformatics Group ** 00006 ** Website: www.iclcv.org and ** 00007 ** http://opensource.cit-ec.de/projects/icl ** 00008 ** ** 00009 ** File : ICLCV/src/ICLCV/CornerDetectorCSS.h ** 00010 ** Module : ICLCV ** 00011 ** Authors: Erik Weitnauer ** 00012 ** ** 00013 ** ** 00014 ** GNU LESSER GENERAL PUBLIC LICENSE ** 00015 ** This file may be used under the terms of the GNU Lesser General ** 00016 ** Public License version 3.0 as published by the ** 00017 ** ** 00018 ** Free Software Foundation and appearing in the file LICENSE.LGPL ** 00019 ** included in the packaging of this file. Please review the ** 00020 ** following information to ensure the license requirements will ** 00021 ** be met: http://www.gnu.org/licenses/lgpl-3.0.txt ** 00022 ** ** 00023 ** The development of this software was supported by the ** 00024 ** Excellence Cluster EXC 277 Cognitive Interaction Technology. ** 00025 ** The Excellence Cluster EXC 277 is a grant of the Deutsche ** 00026 ** Forschungsgemeinschaft (DFG) in the context of the German ** 00027 ** Excellence Initiative. ** 00028 ** ** 00029 ********************************************************************/ 00030 00031 #pragma once 00032 00033 #include <ICLUtils/CompatMacros.h> 00034 #include <ICLUtils/Point32f.h> 00035 #include <ICLUtils/Configurable.h> 00036 #include <ICLCore/Types.h> 00037 #include <vector> 00038 #include <ICLUtils/Uncopyable.h> 00039 00040 namespace icl{ 00041 namespace cv{ 00042 00044 00089 class ICLCV_API CornerDetectorCSS : public utils::Configurable, public utils::Uncopyable{ 00090 public: 00092 struct ICLCV_API GaussianKernel { 00093 std::vector<icl32f> gau; 00094 float sigma; 00095 float cutoff; 00096 int width; // only one side of the gaussian, gau has width*2+1 elements! 00097 GaussianKernel(): sigma(0), cutoff(0), width(0) {} 00098 }; 00099 00101 CornerDetectorCSS(float angle_thresh=162., 00102 float rc_coeff=1.5, 00103 float sigma=3., 00104 float curvature_cutoff=100., 00105 float straight_line_thresh=0.1, 00106 bool accurate = false); 00107 00109 ~CornerDetectorCSS(); 00110 00112 virtual void setPropertyValue(const std::string &propertyName, 00113 const utils::Any &value) throw (utils::ICLException); 00114 00116 virtual std::vector<std::string> getPropertyList() const; 00117 00119 virtual std::string getPropertyType(const std::string &propertyName) const; 00120 00122 virtual std::string getPropertyInfo(const std::string &propertyName) const; 00123 00125 virtual utils::Any getPropertyValue(const std::string &propertyName) const; 00126 00128 virtual inline int getPropertyVolatileness(const std::string &propertyName) const { return 0; } 00129 00131 virtual std::string getPropertyToolTip(const std::string &propertyName) const; 00132 00134 00140 static int gaussian(GaussianKernel &gauss, float sigma, float cutoff); 00141 00143 00154 template<class T> ICLCV_API 00155 const std::vector<std::vector<utils::Point32f> > &detectCorners(const std::vector<std::vector<T> > &boundaries, const std::vector<icl32f> &sigmas); 00156 template<class T> ICLCV_API 00157 const std::vector<utils::Point32f> &detectCorners(const std::vector<T> &boundary); 00158 00160 00161 inline const std::vector<utils::Point32f> &getLastCorners() const { 00162 return corners; 00163 } 00164 00165 inline void setAngleThreshold(float value){ angle_thresh = value; } 00166 inline void setRCCoeff(float value){ rc_coeff = value; } 00167 inline void setSigma(float value){ sigma = value; } 00168 inline void setCurvatureCutoff(float value){ curvature_cutoff = value; } 00169 inline void setStraightLineThreshold(float value) { straight_line_thresh = value; } 00170 inline void setAccurate(bool value) { accurate = value; } 00171 00172 inline float getAngleThreshold() const { return angle_thresh;} 00173 inline float getRCCoeff() const { return rc_coeff; } 00174 inline float getSigma() const { return sigma; } 00175 inline float getCurvatureCutoff() const { return curvature_cutoff; } 00176 inline float getStraightLineThreshold() const { return straight_line_thresh;} 00177 inline bool getAccurate() const { return accurate; } 00178 00180 00196 static void convolute_1D(float *vec, int dim, float *kernel, int kernelDim, float *dst); 00197 00198 private: 00200 float angle_thresh, rc_coeff, sigma, curvature_cutoff, straight_line_thresh; 00202 bool accurate; 00203 00204 int gauss_radius(float sigma, float cutoff); 00205 void fill_gauss(float *mask, float sigma, int width); 00206 void convolute(const float *data, int data_length, const float *mask , int mask_length, float *convoluted); 00207 void calculate_curvatures(const float *smoothed_x, const float *smoothed_y, int length, float curvature_cutoff, float *curvatures); 00208 void calculate_curvatures_bulk(int array_length, int num_boundaries, const int *lengths, 00209 const int *indices, const int *indices_padded, const float *smoothed_x, const float *smoothed_y, float curvature_cutoff, float *curvature); 00210 int findExtrema(int *extrema, int *num_extrema_out, float* k, int length); 00211 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); 00212 void removeRoundCornersAccurate(float rc_coeff, int maxima_offset, float* k, int length, int *extrema, int num_extrema, int *extrema_out, int *num_extrema_out); 00213 float cornerAngle(float *x, float *y, int prev, int current, int next, int length, float straight_line_thresh); 00214 float cornerAngleAccurate(float *x, float *y, int prev, int current, int next, int array_length, float straight_line_thresh); 00215 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); 00216 00217 // result lists 00218 std::vector<utils::Point32f> corners; 00219 std::vector<std::vector<utils::Point32f> > corners_list; 00220 00221 struct CLCurvature; 00222 CLCurvature *clcurvature; 00223 bool useOpenCL; // in case of no support, this is always false 00224 }; 00225 } // namespace core 00226 } 00227