Visual Servoing Platform
version 3.5.1 under development (2023-09-22)
|
#include <visp3/imgproc/vpCircleHoughTransform.h>
Classes | |
class | vpCircleHoughTransformParameters |
Public Member Functions | |
vpCircleHoughTransform () | |
vpCircleHoughTransform (const vpCircleHoughTransformParameters &algoParams) | |
virtual | ~vpCircleHoughTransform () |
std::vector< vpImageCircle > | detect (const vpImage< vpRGBa > &I) |
std::vector< vpImageCircle > | detect (const vpImage< unsigned char > &I) |
std::vector< vpImageCircle > | detect (const vpImage< unsigned char > &I, const int &nbCircles) |
vpCircleHoughTransform (const std::string &jsonPath) | |
void | initFromJSON (const std::string &jsonPath) |
void | saveConfigurationInJSON (const std::string &jsonPath) const |
void | init (const vpCircleHoughTransformParameters &algoParams) |
void | setGaussianParameters (const int &kernelSize, const float &stdev) |
void | setCannyThreshold (const float &lowerCannyThreshold, const float &upperCannyThreshold) |
void | setCircleCenterMinDist (const float ¢er_min_dist) |
void | setCircleCenterBoundingBox (const int ¢er_min_x, const int ¢er_max_x, const int ¢er_min_y, const int ¢er_max_y) |
void | setCircleMinRadius (const float &circle_min_radius) |
void | setCircleMaxRadius (const float &circle_max_radius) |
void | setCirclePerfectness (const float &circle_perfectness) |
void | setCenterComputationParameters (const int &dilatationRepet, const float ¢erThresh) |
void | setRadiusRatioThreshold (const float &radiusRatioThresh) |
void | setRadiusMergingThresholds (const float &radiusDifferenceThresh) |
std::vector< std::pair< int, int > > | getCenterCandidatesList () |
std::vector< int > | getCenterCandidatesVotes () |
std::vector< vpImageCircle > | getCircleCandidates () |
std::vector< unsigned int > | getCircleCandidatesVotes () |
vpImage< float > | getGradientX () |
vpImage< float > | getGradientY () |
vpImage< unsigned char > | getEdgeMap () |
float | getCannyThreshold () const |
float | getCircleCenterMinDist () const |
unsigned int | getCircleMinRadius () const |
unsigned int | getCircleMaxRadius () const |
std::string | toString () const |
Friends | |
void | from_json (const json &j, vpCircleHoughTransform &detector) |
void | to_json (json &j, const vpCircleHoughTransform &detector) |
VISP_EXPORT std::ostream & | operator<< (std::ostream &os, const vpCircleHoughTransform &detector) |
Class that permits to detect 2D circles in a image using the gradient-based Circle Hough transform. Please find more information on the algorithm here
Definition at line 66 of file vpCircleHoughTransform.h.
vpCircleHoughTransform::vpCircleHoughTransform | ( | ) |
Construct a new vpCircleHoughTransform object with default parameters.
Definition at line 38 of file vpCircleHoughTransform.cpp.
vpCircleHoughTransform::vpCircleHoughTransform | ( | const vpCircleHoughTransformParameters & | algoParams | ) |
Construct a new vpCircleHoughTransform object from a vpCircleHoughTransformParameters object.
[in] | algoParams | The parameters of the Circle Hough Transform. |
Definition at line 44 of file vpCircleHoughTransform.cpp.
|
virtual |
Destroy the vp Circle Hough Transform object.
Definition at line 57 of file vpCircleHoughTransform.cpp.
vpCircleHoughTransform::vpCircleHoughTransform | ( | const std::string & | jsonPath | ) |
Construct a new vpCircleHoughTransform object configured according to the JSON file whose path is jsonPath. Throw a vpException error if the file does not exist.
[in] | jsonPath | The path towards the JSON configuration file. |
Definition at line 61 of file vpCircleHoughTransform.cpp.
References initFromJSON().
std::vector< vpImageCircle > vpCircleHoughTransform::detect | ( | const vpImage< unsigned char > & | I | ) |
Perform Circle Hough Transform to detect the circles in a gray-scale image.
[in] | I | The input gray scale image. |
Definition at line 162 of file vpCircleHoughTransform.cpp.
std::vector< vpImageCircle > vpCircleHoughTransform::detect | ( | const vpImage< unsigned char > & | I, |
const int & | nbCircles | ||
) |
Perform Circle Hough Transform to detect the circles in in a gray-scale image. Get only the nbCircles circles having the greatest number of votes.
[in] | I | The input gray scale image. |
[in] | nbCircles | The number of circles we want to get. If negative, all the circles will be returned, sorted such as result[0] has the highest number of votes and result[end -1] the lowest. |
Definition at line 128 of file vpCircleHoughTransform.cpp.
References detect().
std::vector< vpImageCircle > vpCircleHoughTransform::detect | ( | const vpImage< vpRGBa > & | I | ) |
Convert the input image in a gray-scale image and then perform Circle Hough Transform to detect the circles in it.
[in] | I | The input color image. |
Definition at line 110 of file vpCircleHoughTransform.cpp.
References vpImageConvert::convert().
Referenced by detect().
|
inline |
Get internal Canny filter upper threshold. When value is equal to -1 (default), it means that the threshold is computed automatically.
Definition at line 698 of file vpCircleHoughTransform.h.
|
inline |
Get the list of Center Candidates, stored as pair <idRow, idCol>
Definition at line 628 of file vpCircleHoughTransform.h.
|
inline |
Get the number of votes of each Center Candidates.
Definition at line 638 of file vpCircleHoughTransform.h.
|
inline |
Get the Circle Candidates before merging step.
Definition at line 649 of file vpCircleHoughTransform.h.
|
inline |
Get the votes accumulator of the Circle Candidates.
Definition at line 659 of file vpCircleHoughTransform.h.
|
inline |
Get circles center min distance in pixels.
Definition at line 706 of file vpCircleHoughTransform.h.
|
inline |
Get circles max radius in pixels.
Definition at line 722 of file vpCircleHoughTransform.h.
|
inline |
Get circles min radius in pixels.
Definition at line 714 of file vpCircleHoughTransform.h.
|
inline |
Get the Edge Map computed thanks to the Canny edge filter.
Definition at line 689 of file vpCircleHoughTransform.h.
|
inline |
Get the gradient along the horizontal axis of the image.
Definition at line 669 of file vpCircleHoughTransform.h.
|
inline |
Get the gradient along the vertical axis of the image.
Definition at line 679 of file vpCircleHoughTransform.h.
void vpCircleHoughTransform::init | ( | const vpCircleHoughTransformParameters & | algoParams | ) |
Initialize all the algorithm parameters.
[in] | algoParams | The algorithm parameters. |
Definition at line 51 of file vpCircleHoughTransform.cpp.
void vpCircleHoughTransform::initFromJSON | ( | const std::string & | jsonPath | ) |
Initialize all the algorithm parameters using the JSON file whose path is jsonPath. Throw a vpException error if the file does not exist.
[in] | jsonPath | The path towards the JSON configuration file. |
Definition at line 67 of file vpCircleHoughTransform.cpp.
References vpException::ioError.
Referenced by vpCircleHoughTransform().
void vpCircleHoughTransform::saveConfigurationInJSON | ( | const std::string & | jsonPath | ) | const |
Save the configuration of the detector in a JSON file described by the path jsonPath. Throw a vpException is the file cannot be created.
[in] | jsonPath | The path towards the JSON output file. |
Definition at line 93 of file vpCircleHoughTransform.cpp.
References vpCircleHoughTransform::vpCircleHoughTransformParameters::saveConfigurationInJSON().
|
inline |
Set the threshold for the Canny operator. Only value greater than this value are marked as an edge. If negative, the threshold is automatically computed.
[in] | lowerCannyThreshold | : Canny filter lower threshold. When set to -1 (default), compute automatically this threshold. |
[in] | upperCannyThreshold | : Canny filter upper threshold. When set to -1 (default), compute automatically this threshold. |
Definition at line 504 of file vpCircleHoughTransform.h.
|
inline |
Set the parameters of the computation of the circle center candidates.
[in] | dilatationRepet | Number of repetition of the dilatation operation to detect the maxima in the center accumulator. |
[in] | centerThresh | Minimum number of votes a point must exceed to be considered as center candidate. |
Definition at line 582 of file vpCircleHoughTransform.h.
References vpException::badValue.
|
inline |
Set circles center min and max location in the image. If one value is equal to std::numeric_limits<int>::min or std::numeric_limits<int>::max(), the algorithm will set it either to -maxRadius or +maxRadius depending on if it is the lower or upper limit that is missing.
[in] | center_min_x | : Center min location on the horizontal axis, expressed in pixels. |
[in] | center_max_x | : Center max location on the horizontal axis, expressed in pixels. |
[in] | center_min_y | : Center min location on the vertical axis, expressed in pixels. |
[in] | center_max_y | : Center max location on the vertical axis, expressed in pixels. |
Definition at line 537 of file vpCircleHoughTransform.h.
|
inline |
Set circles center min distance. Change this value to detect circles with different distances to each other.
[in] | center_min_dist | : Center min distance in pixels. |
Definition at line 516 of file vpCircleHoughTransform.h.
References vpException::badValue.
|
inline |
Set circles max radius.
[in] | circle_max_radius | : Max radius in pixels. |
Definition at line 559 of file vpCircleHoughTransform.h.
|
inline |
Set circles min radius.
[in] | circle_min_radius | : Min radius in pixels. |
Definition at line 550 of file vpCircleHoughTransform.h.
|
inline |
Set circles perfectness. The scalar product radius RC_ij . gradient(Ep_j) >= m_circlePerfectness * || RC_ij || * || gradient(Ep_j) || to add a vote for the radius RC_ij.
[in] | circle_perfectness | : Circle perfectness. Value between 0 and 1. A perfect circle has value 1. |
Definition at line 568 of file vpCircleHoughTransform.h.
References vpException::badValue.
|
inline |
Set the parameters of the Gaussian filter, that computes the gradients of the image.
[in] | kernelSize | The size of the Gaussian kernel. Must be an odd value. |
[in] | stdev | The standard deviation of the Gaussian function. |
Definition at line 479 of file vpCircleHoughTransform.h.
References vpException::badValue.
|
inline |
Set the radius merging threshold used during the merging step in order to merge the circles that are similar.
[in] | radiusDifferenceThresh | Maximum radius difference between two circle candidates to consider merging them. |
Definition at line 612 of file vpCircleHoughTransform.h.
References vpException::badValue.
|
inline |
Set the parameters of the computation of the circle radius candidates.
[in] | radiusRatioThresh | Minimum number of votes per radian a radius candidate RC_ij of a center candidate CeC_i must have in order that the circle of center CeC_i and radius RC_ij must be considered as circle candidate. |
Definition at line 597 of file vpCircleHoughTransform.h.
References vpException::badValue.
std::string vpCircleHoughTransform::toString | ( | ) | const |
Create a string with all Hough transform parameters.
Definition at line 574 of file vpCircleHoughTransform.cpp.
References vpCircleHoughTransform::vpCircleHoughTransformParameters::toString().
|
friend |
Read the detector configuration from JSON. All values are optional and if an argument is not present, the default value defined in the constructor is kept.
[in] | j | The JSON object, resulting from the parsing of a JSON file. |
[out] | detector | The detector, that will be initialized from the JSON data. |
Definition at line 447 of file vpCircleHoughTransform.h.
|
friend |
Create a ostream with all Hough transform parameters.
Definition at line 579 of file vpCircleHoughTransform.cpp.
|
friend |
Parse a vpCircleHoughTransform into JSON format.
[out] | j | A JSON parser object. |
[in] | detector | The vpCircleHoughTransform that must be parsed into JSON format. |
Definition at line 458 of file vpCircleHoughTransform.h.