![]() |
Visual Servoing Platform version 3.6.0
|
The Circle Hough Transform (CHT) is an image processing algorithm that permits to detect circles in an image. We refer the interested reader to the Wikipedia page to have a better understanding on the principles of the algorithm.
The ViSP implementation relies on the Gradient-based implementation of the algorithm.
During the step where the algorithm votes for center candidates, we use the gradient information in order to reduce the dimensionality of the search space. Instead of voting in circular pattern, we vote along a straight line that follows the gradient.
Then, during the step where the algorithm votes for radius candidates for each center candidate, we check the colinearity between the gradient at a considered point and the line which links the point towards the center candidate. If they are "enough" colinear, we increment the corresponding radius bin vote by 1. The "enough" characteristic is controlled by the circle perfectness parameter.
With the current implementation, the vpCircleHoughTransform
requires ViSP to be compiled with OpenCV. If you do not know how to do it, please refer to the installation guidelines of OpenCV.
It is possible to configure the vpCircleHoughTransform
class using a JSON file. To do so, you need to install JSON for modern C++ and compile ViSP with it.
You can also configure the vpCircleHoughTransform
class using command line arguments. To know what are the different command line arguments the software accept, please run:
To run the software on the synthetic images using a JSON configuration file, please run:
To run the software on the synthetic images using the default parameters, please run:
To run the software on an actual image like coins2.jpg
provided with the tutorial and using a JSON configuration file, please run:
config/detector_img.json
has been tuned to detect circles in the image coins2.jpg
. If the detections seem a bit off, you might need to change the parameters in config/detector_img.json
.To run the software on an actual image using command line arguments instead, please run:
If the detections seem a bit off, you might need to change the parameters
You can use the software to run circle detection on a video saved as a sequence of images that are named ${BASENAME}d.png
. For instance with ${BASENAME}
= video_
, you can have the following list of images: video_0001.png
, video_0002.png
and so on.
To run the software using a JSON configuration file, please run:
To run the software using the command arguments, please run:
An enumeration permits to choose between the different types of synthetic images or using actual images or videos:
You can choose the type you want using the command line arguments. To know how to do it, please run:
If you decide to use a video as input, the relevant piece of code that permits to perform circle detection on the successive images of the video is the following:
If you decide to use a single image as input, the relevant piece of code that permits to perform circle detection on the image is the following:
If you decide to use a synthetic image as input, the relevant piece of code that launches the detection on the synthetic image is the following:
The function that draws the synthetic image is the following:
It relies on the following function to draw the disks:
If you did not use a JSON file to configure the vpCircleHoughTransform
detector, the following structure defines the parameters of the algorithm based on the command line arguments:
The initialization of the algorithm is performed in the following piece of code. If a JSON configuration file is given as input configuration, it will be preferred to the command line arguments:
To run the circle detection, you must call the following method:
You could have also used the following method to get only the num_best
best detections:
Then, you can iterate on the vector of detections using a synthax similar to the following: