Visual Servoing Platform  version 3.6.1 under development (2024-04-29)
vpCircleHoughTransform::vpCircleHoughTransformParameters Class Reference

#include <visp3/imgproc/vpCircleHoughTransform.h>

Public Member Functions

 vpCircleHoughTransformParameters ()
 
 vpCircleHoughTransformParameters (const int &gaussianKernelSize, const float &gaussianStdev, const int &gradientFilterKernelSize, const float &lowerCannyThresh, const float &upperCannyThresh, const int &edgeMapFilterNbIter, const std::pair< int, int > &centerXlimits, const std::pair< int, int > &centerYlimits, const float &minRadius, const float &maxRadius, const int &dilatationKernelSize, const int &averagingWindowSize, const float &centerThresh, const float &circleProbabilityThresh, const float &circlePerfectness, const float &centerMinDistThresh, const float &mergingRadiusDiffThresh, const vpImageFilter::vpCannyFilteringAndGradientType &filteringAndGradientMethod=vpImageFilter::CANNY_GBLUR_SOBEL_FILTERING, const vpImageFilter::vpCannyBackendType &backendType=vpImageFilter::CANNY_OPENCV_BACKEND, const float &lowerCannyThreshRatio=0.6f, const float &upperCannyThreshRatio=0.8f, const int &expectedNbCenters=-1, const bool &recordVotingPoints=false, const float &visibilityRatioThresh=0.1f)
 
int getGaussianKernelSize () const
 
float getGaussianStdev () const
 
int getGradientKernelSize () const
 
float getLowerCannyThreshold () const
 
float getUpperCannyThreshold () const
 
int getEdgeMapFilteringNbIter () const
 
std::pair< int, int > getCenterXLimits () const
 
std::pair< int, int > getCenterYLimits () const
 
float getMinRadius () const
 
float getMaxRadius () const
 
int getDilatationKernelSize () const
 
int getAveragingWindowSize () const
 
float getCenterMinThreshold () const
 
int getExpectedNbCenters () const
 
float getProbabilityThreshold () const
 
float getVisibilityRatioThreshold () const
 
float getCirclePerfectness () const
 
bool getRecordVotingPoints () const
 
float getCenterMinDist () const
 
float getMergingRadiusDiff () const
 
std::string toString () const
 
void saveConfigurationInJSON (const std::string &jsonPath) const
 

Static Public Member Functions

static vpCircleHoughTransformParameters createFromJSON (const std::string &jsonFile)
 

Friends

class vpCircleHoughTransform
 
void from_json (const nlohmann::json &j, vpCircleHoughTransformParameters &params)
 
void to_json (nlohmann::json &j, const vpCircleHoughTransformParameters &params)
 

Detailed Description

Class that gather the algorithm parameters.

Examples
tutorial-circle-hough.cpp.

Definition at line 68 of file vpCircleHoughTransform.h.

Constructor & Destructor Documentation

◆ vpCircleHoughTransformParameters() [1/2]

vpCircleHoughTransform::vpCircleHoughTransformParameters::vpCircleHoughTransformParameters ( )
inline

Construct a new vpCircleHoughTransformParameters object with default parameters.

Definition at line 124 of file vpCircleHoughTransform.h.

◆ vpCircleHoughTransformParameters() [2/2]

vpCircleHoughTransform::vpCircleHoughTransformParameters::vpCircleHoughTransformParameters ( const int &  gaussianKernelSize,
const float &  gaussianStdev,
const int &  gradientFilterKernelSize,
const float &  lowerCannyThresh,
const float &  upperCannyThresh,
const int &  edgeMapFilterNbIter,
const std::pair< int, int > &  centerXlimits,
const std::pair< int, int > &  centerYlimits,
const float &  minRadius,
const float &  maxRadius,
const int &  dilatationKernelSize,
const int &  averagingWindowSize,
const float &  centerThresh,
const float &  circleProbabilityThresh,
const float &  circlePerfectness,
const float &  centerMinDistThresh,
const float &  mergingRadiusDiffThresh,
const vpImageFilter::vpCannyFilteringAndGradientType filteringAndGradientMethod = vpImageFilter::CANNY_GBLUR_SOBEL_FILTERING,
const vpImageFilter::vpCannyBackendType backendType = vpImageFilter::CANNY_OPENCV_BACKEND,
const float &  lowerCannyThreshRatio = 0.6f,
const float &  upperCannyThreshRatio = 0.8f,
const int &  expectedNbCenters = -1,
const bool &  recordVotingPoints = false,
const float &  visibilityRatioThresh = 0.1f 
)
inline

Construct a new vpCircleHoughTransformParameters object.

Parameters
[in]gaussianKernelSizeSize of the Gaussian filter kernel used to smooth the input image. Must be an odd number.
[in]gaussianStdevStandard deviation of the Gaussian filter.
[in]gradientFilterKernelSizeSize of the Sobel or Scharr kernels used to compute the gradients. Must be an odd number.
[in]lowerCannyThreshThe lower threshold for the Canny operator. Values lower than this value are rejected. A negative value makes the algorithm compute this threshold and the lower one automatically.
[in]upperCannyThreshThe upper threshold for the Canny operator. Only values greater than this value are marked as an edge. A negative value makes the algorithm compute this threshold and the lower one automatically.
[in]edgeMapFilterNbIterNumber of 8-neighbor connectivity filtering iterations to apply to the edge map.
[in]centerXlimitsMinimum and maximum position on the horizontal axis of the center of the circle we want to detect.
[in]centerYlimitsMinimum and maximum position on the vertical axis of the center of the circle we want to detect.
[in]minRadiusMinimum radius of the circles we want to detect.
[in]maxRadiusMaximum radius of the circles we want to detect.
[in]dilatationKernelSizeKernel size of the dilatation that is performed to detect the maximum number of votes for the center candidates.
[in]averagingWindowSizeSize of the averaging window around the maximum number of votes to compute the center candidate such as it is the barycenter of the window. Must be odd.
[in]centerThreshMinimum number of votes a point must exceed to be considered as center candidate.
[in]circleProbabilityThreshProbability threshold in order to keep a circle candidate.
[in]circlePerfectnessThe threshold for the colinearity between the gradient of a point and the radius it would form with a center candidate to be able to vote. The formula to get the equivalent angle is: angle = acos(circle_perfectness).
[in]centerMinDistThreshTwo circle candidates whose centers are closer than this threshold are considered for merging.
[in]mergingRadiusDiffThreshMaximum radius difference between two circle candidates to consider merging them.
[in]filteringAndGradientMethodThe choice of the filter and gradient operator to apply before the edge detection step.
[in]backendTypePermits to choose the backend used to compute the edge map.
[in]lowerCannyThreshRatioIf the thresholds must be computed,the lower threshold will be equal to the upper threshold times lowerThresholdRatio .
[in]upperCannyThreshRatioIf the thresholds must be computed,the upper threshold will be equal to the value such as the number of pixels of the image times upperThresholdRatio have an absolute gradient lower than the upper threshold.
[in]expectedNbCentersExpected number of centers in the image. If the number is negative, all the centers are kept. Otherwise, maximum up to this number of centers are kept.
[in]recordVotingPointsIf true, the edge-map points having voted for each circle will be stored.
[in]visibilityRatioThreshVisibility threshold: which minimum ratio of the circle must be visible in order to keep a circle candidate.

Definition at line 191 of file vpCircleHoughTransform.h.

Member Function Documentation

◆ createFromJSON()

static vpCircleHoughTransformParameters vpCircleHoughTransform::vpCircleHoughTransformParameters::createFromJSON ( const std::string &  jsonFile)
inlinestatic

Create a new vpCircleHoughTransformParameters from a JSON file.

Parameters
[in]jsonFileThe path towards the JSON file.
Returns
vpCircleHoughTransformParameters The corresponding vpCircleHoughTransformParameters object.

Definition at line 496 of file vpCircleHoughTransform.h.

References vpException::ioError.

◆ getAveragingWindowSize()

int vpCircleHoughTransform::vpCircleHoughTransformParameters::getAveragingWindowSize ( ) const
inline

Get the size of the averaging window around the maximum number of votes to compute the center candidate such as it is the barycenter of the window.

Returns
int The size of the averaging window.

Definition at line 362 of file vpCircleHoughTransform.h.

◆ getCenterMinDist()

float vpCircleHoughTransform::vpCircleHoughTransformParameters::getCenterMinDist ( ) const
inline

Get the Maximum distance between two circle candidates centers to consider merging them.

Returns
float The maximum distance between two centers.

Definition at line 435 of file vpCircleHoughTransform.h.

◆ getCenterMinThreshold()

float vpCircleHoughTransform::vpCircleHoughTransformParameters::getCenterMinThreshold ( ) const
inline

Get the minimum number of votes a point must exceed to be considered as center candidate.

Returns
float The threshold.

Definition at line 372 of file vpCircleHoughTransform.h.

◆ getCenterXLimits()

std::pair<int, int> vpCircleHoughTransform::vpCircleHoughTransformParameters::getCenterXLimits ( ) const
inline

Get the minimum and maximum position on the horizontal axis of the center of the circle we want to detect.

Returns
std::pair<int, int> The min and max x positions.

Definition at line 310 of file vpCircleHoughTransform.h.

◆ getCenterYLimits()

std::pair<int, int> vpCircleHoughTransform::vpCircleHoughTransformParameters::getCenterYLimits ( ) const
inline

Get the minimum and maximum position on the vertical axis of the center of the circle we want to detect.

Returns
std::pair<int, int> The min and max y positions.

Definition at line 320 of file vpCircleHoughTransform.h.

◆ getCirclePerfectness()

float vpCircleHoughTransform::vpCircleHoughTransformParameters::getCirclePerfectness ( ) const
inline

Get the threshold for the colinearity between the gradient of a point and the radius it would form with a center candidate to be able to vote. The formula to get the equivalent angle is: angle = acos(circle_perfectness).

Returns
float The threshold.

Definition at line 415 of file vpCircleHoughTransform.h.

◆ getDilatationKernelSize()

int vpCircleHoughTransform::vpCircleHoughTransformParameters::getDilatationKernelSize ( ) const
inline

Get the kernel size of the dilatation that is performed to detect the maximum number of votes for the center candidates.

Returns
int The kernel size.

Definition at line 351 of file vpCircleHoughTransform.h.

◆ getEdgeMapFilteringNbIter()

int vpCircleHoughTransform::vpCircleHoughTransformParameters::getEdgeMapFilteringNbIter ( ) const
inline

Get the number of iterations of 8-neighbor connectivity filtering to apply to the edge map.

Returns
int The number of iterations.

Definition at line 300 of file vpCircleHoughTransform.h.

◆ getExpectedNbCenters()

int vpCircleHoughTransform::vpCircleHoughTransformParameters::getExpectedNbCenters ( ) const
inline

Get the expected number of centers in the image. If the number is negative, all the centers are kept. Otherwise, maximum up to this number of centers are kept.

Returns
int The expected number of centers.

Definition at line 383 of file vpCircleHoughTransform.h.

◆ getGaussianKernelSize()

int vpCircleHoughTransform::vpCircleHoughTransformParameters::getGaussianKernelSize ( ) const
inline

Get the size of the Gaussian filter kernel used to smooth the input image.

Returns
int The size of the kernel.

Definition at line 248 of file vpCircleHoughTransform.h.

◆ getGaussianStdev()

float vpCircleHoughTransform::vpCircleHoughTransformParameters::getGaussianStdev ( ) const
inline

Get the standard deviation of the Gaussian filter.

Returns
float The standard deviation.

Definition at line 258 of file vpCircleHoughTransform.h.

◆ getGradientKernelSize()

int vpCircleHoughTransform::vpCircleHoughTransformParameters::getGradientKernelSize ( ) const
inline

Get the size of the gradient kernel filters used to compute the gradients.

Returns
int The size of the kernel.

Definition at line 268 of file vpCircleHoughTransform.h.

◆ getLowerCannyThreshold()

float vpCircleHoughTransform::vpCircleHoughTransformParameters::getLowerCannyThreshold ( ) const
inline

Get the lower threshold for the Canny operator. Values lower than this value are rejected. A negative value means that the algorithm computes the lower threshold automatically.

Returns
float The lower Canny threshold.

Definition at line 279 of file vpCircleHoughTransform.h.

◆ getMaxRadius()

float vpCircleHoughTransform::vpCircleHoughTransformParameters::getMaxRadius ( ) const
inline

Get the maximum radius of the circles we want to detect.

Returns
float The radius max.

Definition at line 340 of file vpCircleHoughTransform.h.

◆ getMergingRadiusDiff()

float vpCircleHoughTransform::vpCircleHoughTransformParameters::getMergingRadiusDiff ( ) const
inline

Get the Maximum radius difference between two circle candidates to consider merging them.

Returns
float The merging radius difference.

Definition at line 445 of file vpCircleHoughTransform.h.

◆ getMinRadius()

float vpCircleHoughTransform::vpCircleHoughTransformParameters::getMinRadius ( ) const
inline

Get the minimum radius of the circles we want to detect.

Returns
float The radius min.

Definition at line 330 of file vpCircleHoughTransform.h.

◆ getProbabilityThreshold()

float vpCircleHoughTransform::vpCircleHoughTransformParameters::getProbabilityThreshold ( ) const
inline

Get the probability threshold in order to keep a circle candidate.

Returns
float The threshold.

Definition at line 393 of file vpCircleHoughTransform.h.

◆ getRecordVotingPoints()

bool vpCircleHoughTransform::vpCircleHoughTransformParameters::getRecordVotingPoints ( ) const
inline

Get the boolean indicating if we have to record the edge-map points having voted for the circles.

Returns
bool True if we have to record the voting points.

Definition at line 425 of file vpCircleHoughTransform.h.

◆ getUpperCannyThreshold()

float vpCircleHoughTransform::vpCircleHoughTransformParameters::getUpperCannyThreshold ( ) const
inline

Get the upper threshold for the Canny operator. Values lower than this value are rejected. A negative value means that the algorithm computes the lower and upper thresholds automatically.

Returns
float The upper Canny threshold.

Definition at line 290 of file vpCircleHoughTransform.h.

◆ getVisibilityRatioThreshold()

float vpCircleHoughTransform::vpCircleHoughTransformParameters::getVisibilityRatioThreshold ( ) const
inline

Get the visibility ratio threshold in order to keep a circle candidate.

Returns
float The threshold.

Definition at line 403 of file vpCircleHoughTransform.h.

◆ saveConfigurationInJSON()

void vpCircleHoughTransform::vpCircleHoughTransformParameters::saveConfigurationInJSON ( const std::string &  jsonPath) const
inline

Save the configuration of the detector in a JSON file described by the path jsonPath. Throw a vpException is the file cannot be created.

Parameters
[in]jsonPathThe path towards the JSON output file.

Definition at line 530 of file vpCircleHoughTransform.h.

Referenced by vpCircleHoughTransform::saveConfigurationInJSON().

◆ toString()

std::string vpCircleHoughTransform::vpCircleHoughTransformParameters::toString ( ) const
inline

Create a string with all the Hough transform parameters.

Definition at line 453 of file vpCircleHoughTransform.h.

References vpImageFilter::vpCannyBackendTypeToString(), and vpImageFilter::vpCannyFilteringAndGradientTypeToString().

Referenced by vpCircleHoughTransform::toString().

Friends And Related Function Documentation

◆ from_json

void from_json ( const nlohmann::json &  j,
vpCircleHoughTransformParameters params 
)
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.

Parameters
[in]j: The JSON object, resulting from the parsing of a JSON file.
[out]params: The circle Hough transform parameters that will be initialized from the JSON data.

Definition at line 546 of file vpCircleHoughTransform.h.

◆ to_json

void to_json ( nlohmann::json &  j,
const vpCircleHoughTransformParameters params 
)
friend

Parse a vpCircleHoughTransform into JSON format.

Parameters
[out]j: A JSON parser object.
[in]params: The circle Hough transform parameters that will be serialized in the json object.

Definition at line 624 of file vpCircleHoughTransform.h.

◆ vpCircleHoughTransform

friend class vpCircleHoughTransform
friend

Definition at line 119 of file vpCircleHoughTransform.h.