Image Component Library (ICL)
|
Curvature Corner Detector. More...
#include <CornerDetectorCSS.h>
Classes | |
struct | DebugInformation |
Detailed information about one corner detection run. More... | |
struct | GaussianKernel |
1 dim gaussian kernel More... | |
Public Member Functions | |
CornerDetectorCSS (float angle_thresh=162., float rc_coeff=1.5, float sigma=3., float curvature_cutoff=100., float straight_line_thresh=0.1) | |
Default constructor with given arguments. | |
virtual void | setPropertyValue (const std::string &propertyName, const utils::Any &value) throw (utils::ICLException) |
sets value of a property (always call call_callbacks(propertyName) or Configurable::setPropertyValue) | |
virtual std::vector< std::string > | getPropertyList () const |
returns Configurable property list | |
virtual std::string | getPropertyType (const std::string &propertyName) const |
returns type of given property | |
virtual std::string | getPropertyInfo (const std::string &propertyName) const |
returns info for given property | |
virtual utils::Any | getPropertyValue (const std::string &propertyName) const |
returns value for given property | |
virtual int | getPropertyVolatileness (const std::string &propertyName) const |
returns volatileness for given property | |
virtual std::string | getPropertyToolTip (const std::string &propertyName) const |
returns property descriptions | |
const std::vector < utils::Point32f > & | detectCorners (const std::vector< utils::Point32f > &boundary) |
detects the corners in the passed contour | |
const std::vector < utils::Point32f > & | detectCorners (const std::vector< utils::Point > &boundary) |
detects corners on int-points | |
const std::vector < utils::Point32f > & | getLastCorners () const |
returns the result of last detectCorners call | |
const std::vector< float > & | getCornerAngles () const |
Returns approximated angles of corners in deg. Call detectCorners method first. | |
void | setAngleThreshold (float value) |
void | setRCCoeff (float value) |
void | setSigma (float value) |
void | setCurvatureCutoff (float value) |
void | setStraightLineThreshold (float value) |
float | getAngleThreshold () const |
float | getRCCoeff () const |
float | getSigma () const |
float | getCurvatureCutoff () const |
float | getStraightLineThreshold () const |
void | setDebugMode (bool value) |
const DebugInformation & | getDebugInformation () const throw (utils::ICLException) |
Static Public Member Functions | |
static int | gaussian (GaussianKernel &gauss, float sigma, float cutoff) |
calculates a normalized 1d gaussian std::vector | |
static void | convolute_1D (float *vec, int dim, float *kernel, int kernelDim, float *dst) |
Small wrapper for ippsConv_32f. | |
Static Private Member Functions | |
static void | findExtrema (std::vector< int > &extrema, icl32f *x, int length) |
finds the indicies of extrema | |
static void | removeRoundCorners (float rc_coeff, icl32f *k, std::vector< int > &extrema) |
removes round corners by comparing all corner candidates with adaptive local threshold | |
static void | removeFalseCorners (float angle_thresh, icl32f *xx, icl32f *yy, icl32f *k, int length, std::vector< int > &maxima, std::vector< float > &corner_angles, float straight_line_thresh) |
remove false corners by checking the corner angle | |
static float | tangentAngle (icl32f *x, icl32f *y, int length, int center, float straight_line_thresh) |
estimates the angle of a corner | |
Private Attributes | |
float | angle_thresh |
parameters | |
float | rc_coeff |
float | sigma |
float | curvature_cutoff |
float | straight_line_thresh |
bool | debug_mode |
debug mode flag | |
GaussianKernel | m_gauss |
gausian kernel | |
std::vector< utils::Point32f > | corners |
std::vector< float > | corner_angles |
std::vector< int > | extrema |
std::vector< utils::Point32f > | inputBuffer |
DebugInformation | debug_inf |
Curvature Corner Detector.
Implementation of the Curvature Scale Space corner detection algorithm described in the paper "Corner detector based on global and local curvature properties", by Chen He, Xiao and Yung, Nelson H.C. in Optical Engineering 2008. There also is a Matlab implementation of the algorithm by Chen He, Xiao available at http://www.mathworks.com/matlabcentral/fileexchange/7652
The algorithm takes an array of contour points as input, that are then smoothed by a gaussian filter. Afterwards the curvature function is calculated and its maxima positions are taken as corner candidates. Afterwards all candidates which belong to round or "false" (noise induced, etc.) corners are removed and finally a list of corners is given back.
Parameters for the algorithm are:
Diffent to the reference implementation of Xiao He, the second half of the contour is copied before the start of the contour and the first half of the contour is copied behind the end of the contour. That way, the (artificially) first and last corners in the closed contour are calculated more acurately, since there are no discontinuities.
For visualizing the algorithm, you can call setDebugMode(true) after construction of the CornerDetectionCSS object and retrieve detailed information of the detection process afterwards with the getDebugInformation() method. See the icl-corner-detection-css-demo as an example.
usage example:
const std::vector<icl::Region> &rs = d.detect(&image); const std::vector<Point32f> &boundary = getThinnedBoundary(rs[0].getBoundary()); CornerDetectorCSS css; const std::vector<Point32f> &corners = css.detectCorners(boundary);
icl::cv::CornerDetectorCSS::CornerDetectorCSS | ( | float | angle_thresh = 162. , |
float | rc_coeff = 1.5 , |
||
float | sigma = 3. , |
||
float | curvature_cutoff = 100. , |
||
float | straight_line_thresh = 0.1 |
||
) | [inline] |
Default constructor with given arguments.
static void icl::cv::CornerDetectorCSS::convolute_1D | ( | float * | vec, |
int | dim, | ||
float * | kernel, | ||
int | kernelDim, | ||
float * | dst | ||
) | [static] |
Small wrapper for ippsConv_32f.
vec | |
dim | |
kernel | |
kernelDim | |
dst | destination data pointer of size dim+kernelDim -1 |
Performs the following operation
for all
with for and for
const std::vector<utils::Point32f>& icl::cv::CornerDetectorCSS::detectCorners | ( | const std::vector< utils::Point32f > & | boundary | ) |
detects the corners in the passed contour
Use this function to detect the corners in an image.
A reference to the contour in which the corners should be detected must be passed. The contour should be "thinned", meaning that it should look e.g. like
ooox ooxx ooxo and not like oxxo oxoo xxoo xooo xooo
const std::vector<utils::Point32f>& icl::cv::CornerDetectorCSS::detectCorners | ( | const std::vector< utils::Point > & | boundary | ) |
detects corners on int-points
static void icl::cv::CornerDetectorCSS::findExtrema | ( | std::vector< int > & | extrema, |
icl32f * | x, | ||
int | length | ||
) | [static, private] |
finds the indicies of extrema
extrema | reference to a std::vector in which the extrema are stored |
x | function values |
length | number of points in array x |
static int icl::cv::CornerDetectorCSS::gaussian | ( | GaussianKernel & | gauss, |
float | sigma, | ||
float | cutoff | ||
) | [static] |
calculates a normalized 1d gaussian std::vector
gauss | reference to GaussianKernel struct |
sigma | sigma^2 is the variance of the gaussian, default is 1 |
cutoff | if value of gaussian drops below this value, it is set to zero, default is 0.001 |
float icl::cv::CornerDetectorCSS::getAngleThreshold | ( | ) | const [inline] |
const std::vector<float>& icl::cv::CornerDetectorCSS::getCornerAngles | ( | ) | const [inline] |
Returns approximated angles of corners in deg. Call detectCorners method first.
float icl::cv::CornerDetectorCSS::getCurvatureCutoff | ( | ) | const [inline] |
const DebugInformation& icl::cv::CornerDetectorCSS::getDebugInformation | ( | ) | const throw (utils::ICLException) [inline] |
const std::vector<utils::Point32f>& icl::cv::CornerDetectorCSS::getLastCorners | ( | ) | const [inline] |
returns the result of last detectCorners call
This function can be used as optimization e.g. whithin ICLCV::Region implementation
virtual std::string icl::cv::CornerDetectorCSS::getPropertyInfo | ( | const std::string & | propertyName | ) | const [virtual] |
returns info for given property
Reimplemented from icl::utils::Configurable.
virtual std::vector<std::string> icl::cv::CornerDetectorCSS::getPropertyList | ( | ) | const [virtual] |
returns Configurable property list
Reimplemented from icl::utils::Configurable.
virtual std::string icl::cv::CornerDetectorCSS::getPropertyToolTip | ( | const std::string & | propertyName | ) | const [virtual] |
returns property descriptions
Reimplemented from icl::utils::Configurable.
virtual std::string icl::cv::CornerDetectorCSS::getPropertyType | ( | const std::string & | propertyName | ) | const [virtual] |
returns type of given property
Reimplemented from icl::utils::Configurable.
virtual utils::Any icl::cv::CornerDetectorCSS::getPropertyValue | ( | const std::string & | propertyName | ) | const [virtual] |
returns value for given property
Reimplemented from icl::utils::Configurable.
virtual int icl::cv::CornerDetectorCSS::getPropertyVolatileness | ( | const std::string & | propertyName | ) | const [inline, virtual] |
returns volatileness for given property
Reimplemented from icl::utils::Configurable.
float icl::cv::CornerDetectorCSS::getRCCoeff | ( | ) | const [inline] |
float icl::cv::CornerDetectorCSS::getSigma | ( | ) | const [inline] |
float icl::cv::CornerDetectorCSS::getStraightLineThreshold | ( | ) | const [inline] |
static void icl::cv::CornerDetectorCSS::removeFalseCorners | ( | float | angle_thresh, |
icl32f * | xx, | ||
icl32f * | yy, | ||
icl32f * | k, | ||
int | length, | ||
std::vector< int > & | maxima, | ||
std::vector< float > & | corner_angles, | ||
float | straight_line_thresh | ||
) | [static, private] |
remove false corners by checking the corner angle
The angle threshold denotes the maximum obtuse angle that a corner can have when it is detected as a true corner.
angle_thresh | angle threshold |
xx,yy | x,y dimension of smoothed contour |
k | curvature function |
length | number of points in smoothed contour (and curvature function) |
maxima | indicies of maximum points in curvature function k |
corner_angles | |
straight_line_thresh |
static void icl::cv::CornerDetectorCSS::removeRoundCorners | ( | float | rc_coeff, |
icl32f * | k, | ||
std::vector< int > & | extrema | ||
) | [static, private] |
removes round corners by comparing all corner candidates with adaptive local threshold
The round corner coefficient denotes the minimum ratio of major axis to minor axis of an ellipse, whose vertex could be detected as a corner by proposed detector.
rc_coeff | round corner coefficient |
k | curvature function |
extrema | indicies of extrem points in curvature function k |
void icl::cv::CornerDetectorCSS::setAngleThreshold | ( | float | value | ) | [inline] |
void icl::cv::CornerDetectorCSS::setCurvatureCutoff | ( | float | value | ) | [inline] |
void icl::cv::CornerDetectorCSS::setDebugMode | ( | bool | value | ) | [inline] |
virtual void icl::cv::CornerDetectorCSS::setPropertyValue | ( | const std::string & | propertyName, |
const utils::Any & | value | ||
) | throw (utils::ICLException) [virtual] |
sets value of a property (always call call_callbacks(propertyName) or Configurable::setPropertyValue)
Reimplemented from icl::utils::Configurable.
void icl::cv::CornerDetectorCSS::setRCCoeff | ( | float | value | ) | [inline] |
void icl::cv::CornerDetectorCSS::setSigma | ( | float | value | ) | [inline] |
void icl::cv::CornerDetectorCSS::setStraightLineThreshold | ( | float | value | ) | [inline] |
static float icl::cv::CornerDetectorCSS::tangentAngle | ( | icl32f * | x, |
icl32f * | y, | ||
int | length, | ||
int | center, | ||
float | straight_line_thresh | ||
) | [static, private] |
estimates the angle of a corner
Eestimates the angle of a corner in a part of the curve by fitting a circle on each side of the corner and calculating the angle between the two tangents.
x,y | x,y dimension of the contour segment around the corner |
length | number of points in contour segment |
center | position of corner in contour segment |
straight_line_thresh |
float icl::cv::CornerDetectorCSS::angle_thresh [private] |
parameters
std::vector<float> icl::cv::CornerDetectorCSS::corner_angles [private] |
std::vector<utils::Point32f> icl::cv::CornerDetectorCSS::corners [private] |
float icl::cv::CornerDetectorCSS::curvature_cutoff [private] |
bool icl::cv::CornerDetectorCSS::debug_mode [private] |
debug mode flag
std::vector<int> icl::cv::CornerDetectorCSS::extrema [private] |
std::vector<utils::Point32f> icl::cv::CornerDetectorCSS::inputBuffer [private] |
gausian kernel
float icl::cv::CornerDetectorCSS::rc_coeff [private] |
float icl::cv::CornerDetectorCSS::sigma [private] |
float icl::cv::CornerDetectorCSS::straight_line_thresh [private] |