Visual Servoing Platform  version 3.6.1 under development (2024-12-17)
vpCircleHoughTransform::vpCircleHoughTransformParams Class Reference

#include <visp3/imgproc/vpCircleHoughTransform.h>

Public Member Functions

 vpCircleHoughTransformParams ()
 
 vpCircleHoughTransformParams (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 vpCircleHoughTransformParams createFromJSON (const std::string &jsonFile)
 

Friends

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

Detailed Description

Class that gather the algorithm parameters.

Examples
tutorial-circle-hough.cpp.

Definition at line 70 of file vpCircleHoughTransform.h.

Constructor & Destructor Documentation

◆ vpCircleHoughTransformParams() [1/2]

vpCircleHoughTransform::vpCircleHoughTransformParams::vpCircleHoughTransformParams ( )
inline

Construct a new vpCircleHoughTransformParams object with default parameters.

Definition at line 76 of file vpCircleHoughTransform.h.

◆ vpCircleHoughTransformParams() [2/2]

vpCircleHoughTransform::vpCircleHoughTransformParams::vpCircleHoughTransformParams ( 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 vpCircleHoughTransformParams 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 147 of file vpCircleHoughTransform.h.

Member Function Documentation

◆ createFromJSON()

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

Create a new vpCircleHoughTransformParams from a JSON file.

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

Definition at line 453 of file vpCircleHoughTransform.h.

References vpException::ioError.

◆ getAveragingWindowSize()

int vpCircleHoughTransform::vpCircleHoughTransformParams::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 318 of file vpCircleHoughTransform.h.

◆ getCenterMinDist()

float vpCircleHoughTransform::vpCircleHoughTransformParams::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 391 of file vpCircleHoughTransform.h.

◆ getCenterMinThreshold()

float vpCircleHoughTransform::vpCircleHoughTransformParams::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 328 of file vpCircleHoughTransform.h.

◆ getCenterXLimits()

std::pair<int, int> vpCircleHoughTransform::vpCircleHoughTransformParams::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 266 of file vpCircleHoughTransform.h.

◆ getCenterYLimits()

std::pair<int, int> vpCircleHoughTransform::vpCircleHoughTransformParams::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 276 of file vpCircleHoughTransform.h.

◆ getCirclePerfectness()

float vpCircleHoughTransform::vpCircleHoughTransformParams::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 371 of file vpCircleHoughTransform.h.

◆ getDilatationKernelSize()

int vpCircleHoughTransform::vpCircleHoughTransformParams::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 307 of file vpCircleHoughTransform.h.

◆ getEdgeMapFilteringNbIter()

int vpCircleHoughTransform::vpCircleHoughTransformParams::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 256 of file vpCircleHoughTransform.h.

◆ getExpectedNbCenters()

int vpCircleHoughTransform::vpCircleHoughTransformParams::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 339 of file vpCircleHoughTransform.h.

◆ getGaussianKernelSize()

int vpCircleHoughTransform::vpCircleHoughTransformParams::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 204 of file vpCircleHoughTransform.h.

◆ getGaussianStdev()

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

Get the standard deviation of the Gaussian filter.

Returns
float The standard deviation.

Definition at line 214 of file vpCircleHoughTransform.h.

◆ getGradientKernelSize()

int vpCircleHoughTransform::vpCircleHoughTransformParams::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 224 of file vpCircleHoughTransform.h.

◆ getLowerCannyThreshold()

float vpCircleHoughTransform::vpCircleHoughTransformParams::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 235 of file vpCircleHoughTransform.h.

◆ getMaxRadius()

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

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

Returns
float The radius max.

Definition at line 296 of file vpCircleHoughTransform.h.

◆ getMergingRadiusDiff()

float vpCircleHoughTransform::vpCircleHoughTransformParams::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 401 of file vpCircleHoughTransform.h.

◆ getMinRadius()

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

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

Returns
float The radius min.

Definition at line 286 of file vpCircleHoughTransform.h.

◆ getProbabilityThreshold()

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

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

Returns
float The threshold.

Definition at line 349 of file vpCircleHoughTransform.h.

◆ getRecordVotingPoints()

bool vpCircleHoughTransform::vpCircleHoughTransformParams::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 381 of file vpCircleHoughTransform.h.

◆ getUpperCannyThreshold()

float vpCircleHoughTransform::vpCircleHoughTransformParams::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 246 of file vpCircleHoughTransform.h.

◆ getVisibilityRatioThreshold()

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

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

Returns
float The threshold.

Definition at line 359 of file vpCircleHoughTransform.h.

◆ saveConfigurationInJSON()

void vpCircleHoughTransform::vpCircleHoughTransformParams::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 487 of file vpCircleHoughTransform.h.

Referenced by vpCircleHoughTransform::saveConfigurationInJSON().

◆ toString()

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

Create a string with all the Hough transform parameters.

Definition at line 409 of file vpCircleHoughTransform.h.

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

Referenced by vpCircleHoughTransform::toString().

Friends And Related Function Documentation

◆ from_json

void from_json ( const nlohmann::json &  j,
vpCircleHoughTransformParams 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 504 of file vpCircleHoughTransform.h.

◆ to_json

void to_json ( nlohmann::json &  j,
const vpCircleHoughTransformParams 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 583 of file vpCircleHoughTransform.h.

◆ vpCircleHoughTransform

friend class vpCircleHoughTransform
friend

Definition at line 663 of file vpCircleHoughTransform.h.