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.GPL ** 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/Point32f.h> 00034 #include <ICLCore/Types.h> 00035 #include <vector> 00036 #include <ICLUtils/Configurable.h> 00037 00038 namespace icl{ 00039 namespace cv{ 00040 00042 00092 class CornerDetectorCSS : public utils::Configurable{ 00093 public: 00095 struct GaussianKernel { 00096 std::vector<icl32f> gau; 00097 float sigma; 00098 float cutoff; 00099 int width; // only one side of the gaussian, gau has width*2+1 elements! 00100 GaussianKernel(): sigma(0), cutoff(0), width(0) {} 00101 }; 00102 00104 struct DebugInformation { 00105 GaussianKernel gk; 00106 std::vector<utils::Point32f> boundary; 00107 std::vector<utils::Point32f> smoothed_boundary; 00108 std::vector<float> kurvature; 00109 std::vector<int> extrema; 00110 std::vector<int> maxima; 00111 std::vector<int> maxima_without_round_corners; 00112 std::vector<int> maxima_without_false_corners; 00113 std::vector<utils::Point32f> corners; 00114 std::vector<float> angles; 00115 int offset; // the number of additional points at begin and end of 00116 // smoothed_boundary and kurvature 00117 float angle_thresh; 00118 float rc_coeff; 00119 float straight_line_thresh; 00120 }; 00121 00123 CornerDetectorCSS(float angle_thresh=162., 00124 float rc_coeff=1.5, 00125 float sigma=3., 00126 float curvature_cutoff=100., 00127 float straight_line_thresh=0.1): 00128 angle_thresh(angle_thresh), rc_coeff(rc_coeff), sigma(sigma), 00129 curvature_cutoff(curvature_cutoff), straight_line_thresh(straight_line_thresh), 00130 debug_mode(false) {}; 00131 00133 virtual void setPropertyValue(const std::string &propertyName, 00134 const utils::Any &value) throw (utils::ICLException); 00135 00137 virtual std::vector<std::string> getPropertyList() const; 00138 00140 virtual std::string getPropertyType(const std::string &propertyName) const; 00141 00143 virtual std::string getPropertyInfo(const std::string &propertyName) const; 00144 00146 virtual utils::Any getPropertyValue(const std::string &propertyName) const; 00147 00149 virtual inline int getPropertyVolatileness(const std::string &propertyName) const { return 0; } 00150 00152 virtual std::string getPropertyToolTip(const std::string &propertyName) const; 00153 00155 00161 static int gaussian(GaussianKernel &gauss, float sigma, float cutoff); 00162 00164 00175 const std::vector<utils::Point32f> &detectCorners(const std::vector<utils::Point32f> &boundary); 00176 00178 const std::vector<utils::Point32f> &detectCorners(const std::vector<utils::Point> &boundary); 00179 00181 00182 inline const std::vector<utils::Point32f> &getLastCorners() const { 00183 return corners; 00184 } 00185 00187 const std::vector<float> &getCornerAngles() const { return corner_angles; } 00188 00189 inline void setAngleThreshold(float value){ angle_thresh = value; } 00190 inline void setRCCoeff(float value){ rc_coeff = value; } 00191 inline void setSigma(float value){ sigma = value; } 00192 inline void setCurvatureCutoff(float value){ curvature_cutoff = value; } 00193 inline void setStraightLineThreshold(float value) { straight_line_thresh = value; } 00194 00195 inline float getAngleThreshold() const { return angle_thresh;} 00196 inline float getRCCoeff() const { return rc_coeff; } 00197 inline float getSigma() const { return sigma; } 00198 inline float getCurvatureCutoff() const { return curvature_cutoff; } 00199 inline float getStraightLineThreshold() const { return straight_line_thresh;} 00200 00201 inline void setDebugMode(bool value) { debug_mode = value; } 00202 const DebugInformation &getDebugInformation() const throw (utils::ICLException){ 00203 if(!debug_mode) throw utils::ICLException("CornerDetectorCSS::getDebugInformation: not possible: debug mode is off"); 00204 return debug_inf; 00205 } 00206 00208 00223 static void convolute_1D(float *vec, int dim, float *kernel, int kernelDim, float *dst); 00224 00225 private: 00227 float angle_thresh, rc_coeff, sigma, curvature_cutoff, straight_line_thresh; 00229 bool debug_mode; 00230 00232 GaussianKernel m_gauss; 00233 00235 00240 static void findExtrema(std::vector<int> &extrema, icl32f* x, int length); 00241 00243 00250 static void removeRoundCorners( float rc_coeff, icl32f* k, std::vector<int> &extrema); 00251 00253 00264 static void removeFalseCorners(float angle_thresh, icl32f* xx, icl32f* yy, icl32f* k, 00265 int length, std::vector<int> &maxima, std::vector<float> &corner_angles, 00266 float straight_line_thresh); 00267 00269 00277 static float tangentAngle(icl32f* x, icl32f* y, int length, int center, float straight_line_thresh); 00278 00279 // result lists 00280 std::vector<utils::Point32f> corners; 00281 std::vector<float> corner_angles; 00282 std::vector<int> extrema; 00283 std::vector<utils::Point32f> inputBuffer; 00284 DebugInformation debug_inf; 00285 }; 00286 } // namespace core 00287 } 00288