CircleHoughTransform¶
- class CircleHoughTransform(*args, **kwargs)¶
Bases:
pybind11_object
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
Overloaded function.
__init__(self: visp._visp.imgproc.CircleHoughTransform) -> None
Construct a new vpCircleHoughTransform object with default parameters.
__init__(self: visp._visp.imgproc.CircleHoughTransform, algoParams: visp._visp.imgproc.CircleHoughTransform.CircleHoughTransformParams) -> None
__init__(self: visp._visp.imgproc.CircleHoughTransform, jsonPath: str) -> None
Methods
Overloaded function.
Compute the mask containing pixels that voted for the detections .
Overloaded function.
Get internal Canny filter upper threshold.
Get the list of Center Candidates, stored as pair <idRow, idCol>
Get the number of votes of each Center Candidates.
Get the Circle Candidates before merging step.
Get the probabilities of the Circle Candidates.
Get the votes of the circle candidates.
Get circles center min distance in pixels.
Get circles max radius in pixels.
Get circles min radius in pixels.
Get the probabilities of the detections that are outputed by vpCircleHoughTransform::detect()
Get the number of votes for the detections that are outputed by vpCircleHoughTransform::detect()
Get the points that voted for the detections that are outputed by vpCircleHoughTransform::detect() .
Get the Edge Map computed thanks to the Canny edge filter.
Get the gradient along the horizontal axis of the image.
Get the gradient along the vertical axis of the image.
Returns true if it was asked to record the points that voted for the detections.
Initialize all the algorithm parameters using the JSON file whose path is jsonPath .
Save the configuration of the detector in a JSON file described by the path jsonPath .
Set the backend to use to perform the Canny edge detection.
Set the threshold for the Canny operator.
Set the Canny thresholds ratio that are used to automatically compute the Canny thresholds in case the user asks to.
Set the parameters of the computation of the circle center candidates.
Set circles center min and max location in the image.
Set circles center min distance.
Set circles max radius.
Set circles min radius.
Set circles perfectness, which corresponds to the threshold of the colinearity between the gradient of a point and the radius it would form with a center candidate to be able to vote.
Permits to choose the filtering + gradient operators to use.
Set the parameters of the Gaussian filter, that permits to blur the gradients of the image.
Set the parameters of the gradient filter (Sobel or Scharr) kernel size filters.
Set the mask that permits to ignore some pixels when performing the circle detection.
Set the radius merging threshold used during the merging step in order to merge the circles that are similar.
Set the parameters of the computation of the circle radius candidates.
Permits to either activate or deactivate the memorization of the points that voted for the detected circles.
Create a string with all Hough transform parameters.
Inherited Methods
Operators
__doc__
Overloaded function.
__module__
__repr__
Attributes
__annotations__
edgeMapOff
edgeMapOn
- __init__(*args, **kwargs)¶
Overloaded function.
__init__(self: visp._visp.imgproc.CircleHoughTransform) -> None
Construct a new vpCircleHoughTransform object with default parameters.
__init__(self: visp._visp.imgproc.CircleHoughTransform, algoParams: visp._visp.imgproc.CircleHoughTransform.CircleHoughTransformParams) -> None
__init__(self: visp._visp.imgproc.CircleHoughTransform, jsonPath: str) -> None
- computeVotingMask(self: visp._visp.imgproc.CircleHoughTransform, I: visp._visp.core.ImageGray, detections: list[visp._visp.core.ImageCircle], mask: Optional[vpImage<bool>], opt_votingPoints: Optional[list[list[tuple[int, int]]]]) None ¶
Compute the mask containing pixels that voted for the detections .
- Parameters:
- I
The image for which we want to have the information.
- detections
Vector containing the list of vpImageCircle for which we want to know the voting points.
- mask
Optional mask where pixels to exclude have a value set to false.
- opt_votingPoints
Optional vector of pairs of pixel coordinates that voted for the detections .
- detect(*args, **kwargs)¶
Overloaded function.
detect(self: visp._visp.imgproc.CircleHoughTransform, cv_I: cv::Mat) -> list[visp._visp.core.ImageCircle]
detect(self: visp._visp.imgproc.CircleHoughTransform, I: visp._visp.core.ImageRGBa) -> list[visp._visp.core.ImageCircle]
Convert the input image in a gray-scale image and then perform Circle Hough Transform to detect the circles in it.
- Parameters:
- I
The input color image.
- Returns:
std::vector<vpImageCircle> The list of 2D circles detected in the image.
detect(self: visp._visp.imgproc.CircleHoughTransform, I: visp._visp.core.ImageGray) -> list[visp._visp.core.ImageCircle]
Perform Circle Hough Transform to detect the circles in a gray-scale image.
- Parameters:
- I
The input gray scale image.
- Returns:
std::vector<vpImageCircle> The list of 2D circles detected in the image.
detect(self: visp._visp.imgproc.CircleHoughTransform, I: visp._visp.core.ImageGray, nbCircles: int) -> list[visp._visp.core.ImageCircle]
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.
- Parameters:
- I
The input gray scale image.
- 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.
- Returns:
std::vector<vpImageCircle> The list of 2D circles with the most number of votes detected in the image.
- getCannyThreshold(self) float ¶
Get internal Canny filter upper threshold. When value is equal to -1 (default), it means that the threshold is computed automatically.
- getCenterCandidatesList(self) list[tuple[float, float]] ¶
Get the list of Center Candidates, stored as pair <idRow, idCol>
- Returns:
std::vector<std::pair<float, float> > The list of Center Candidates, stored as pair <idRow, idCol>
- getCenterCandidatesVotes(self) list[int] ¶
Get the number of votes of each Center Candidates.
- Returns:
std::vector<int> The number of votes of each Center Candidates, ordered in the same way than m_centerCandidatesList .
- getCircleCandidates(self) list[visp._visp.core.ImageCircle] ¶
Get the Circle Candidates before merging step.
- Returns:
std::vector<vpImageCircle> The list of circle candidates that were obtained before the merging step.
- getCircleCandidatesProbabilities(self) list[float] ¶
Get the probabilities of the Circle Candidates.
- Returns:
std::vector<float> The votes accumulator.
- getCircleCandidatesVotes(self) list[int] ¶
Get the votes of the circle candidates.
- Returns:
std::vector<unsigned int> The votes of the circle candidates.
- getDetectionsProbabilities(self) list[float] ¶
Get the probabilities of the detections that are outputed by vpCircleHoughTransform::detect()
- getDetectionsVotes(self) list[int] ¶
Get the number of votes for the detections that are outputed by vpCircleHoughTransform::detect()
- getDetectionsVotingPoints(self) list[list[tuple[int, int]]] ¶
Get the points that voted for the detections that are outputed by vpCircleHoughTransform::detect() .
- getEdgeMap(self) visp._visp.core.ImageGray ¶
Get the Edge Map computed thanks to the Canny edge filter.
- Returns:
vpImage<unsigned char> The edge map computed during the edge detection step.
- getGradientX(self) visp._visp.core.ImageFloat ¶
Get the gradient along the horizontal axis of the image.
- Returns:
vpImage<float> The gradient along the horizontal axis of the image.
- getGradientY(self) visp._visp.core.ImageFloat ¶
Get the gradient along the vertical axis of the image.
- Returns:
vpImage<float> The gradient along the vertical axis of the image.
- getRecordVotingPoints(self) bool ¶
Returns true if it was asked to record the points that voted for the detections.
- initFromJSON(self, jsonPath: str) None ¶
Initialize all the algorithm parameters using the JSON file whose path is jsonPath . Throw a ** vpException ** error if the file does not exist.
- saveConfigurationInJSON(self, jsonPath: str) None ¶
Save the configuration of the detector in a JSON file described by the path jsonPath . Throw a ** vpException ** is the file cannot be created.
- setCannyBackend(self, type: visp._visp.core.ImageFilter.CannyBackendType) None ¶
Set the backend to use to perform the Canny edge detection.
- Parameters:
- type: visp._visp.core.ImageFilter.CannyBackendType¶
The backend that must be used.
- setCannyThreshold(self, lowerCannyThreshold: float, upperCannyThreshold: float) None ¶
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.
- setCannyThresholdRatio(self, lowerThreshRatio: float, upperThreshRatio: float) None ¶
Set the Canny thresholds ratio that are used to automatically compute the Canny thresholds in case the user asks to.
Note
See vpCircleHoughTransform::setCannyThreshold(const float&, const float&)
- setCenterComputationParameters(self, dilatationSize: int, centerThresh: float, averagingWindowSize: int = 5, expectedNbCenters: int = -1) None ¶
Set the parameters of the computation of the circle center candidates.
- Parameters:
- dilatationSize: int¶
Kernel size of the dilatation operation used to detect the maxima in the center accumulator.
- centerThresh: float¶
Minimum number of votes a point must exceed to be considered as center candidate.
- averagingWindowSize: int = 5¶
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. Must be odd.
- expectedNbCenters: int = -1¶
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.
- setCircleCenterBoundingBox(self, center_min_x: int, center_max_x: int, center_min_y: int, center_max_y: int) None ¶
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.
- Parameters:
- center_min_x: int¶
Center min location on the horizontal axis, expressed in pixels.
- center_max_x: int¶
Center max location on the horizontal axis, expressed in pixels.
- center_min_y: int¶
Center min location on the vertical axis, expressed in pixels.
- center_max_y: int¶
Center max location on the vertical axis, expressed in pixels.
- setCircleCenterMinDist(self, center_min_dist: float) None ¶
Set circles center min distance. Change this value to detect circles with different distances to each other.
- setCircleMaxRadius(self, circle_max_radius: float) None ¶
Set circles max radius.
- setCircleMinRadius(self, circle_min_radius: float) None ¶
Set circles min radius.
- setCirclePerfectness(self, circle_perfectness: float) None ¶
Set circles perfectness, which corresponds to the threshold of 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) .
- setFilteringAndGradientType(self, type: visp._visp.core.ImageFilter.CannyFilteringAndGradientType) None ¶
Permits to choose the filtering + gradient operators to use.
- Parameters:
- type: visp._visp.core.ImageFilter.CannyFilteringAndGradientType¶
The type of filtering + gradient operators to use.
- setGaussianParameters(self, kernelSize: int, stdev: float) None ¶
Set the parameters of the Gaussian filter, that permits to blur the gradients of the image.
- setGradientFilterAperture(self, apertureSize: int) None ¶
Set the parameters of the gradient filter (Sobel or Scharr) kernel size filters.
- setMask(self: visp._visp.imgproc.CircleHoughTransform, mask: vpImage<bool>) None ¶
Set the mask that permits to ignore some pixels when performing the circle detection.
- Parameters:
- mask
A boolean image where pixels set to true means that the pixel must be considered and set to false means that the pixel must be ignored.
- setRadiusMergingThresholds(self, radiusDifferenceThresh: float) None ¶
Set the radius merging threshold used during the merging step in order to merge the circles that are similar.
- setRadiusRatioThreshold(self, radiusRatioThresh: float) None ¶
Set the parameters of the computation of the circle radius candidates.