I was looking at how to detect billiard balls on a pool table, when I stumbled upon this post.
The OP states that he employs the Canny edge detection algorithm on the hue channel of his video feed before applying the circle Hough transform. Is there any computational benefit to performing the edge detection before the circle detection, or should I immediately perform circle detection on the video feed?
Thanks in advance!
In general, you could do a dense Hough or a sparse Hough, and you could have weighted or unweighted votes.
By grayscale level (intensity):
By position/density/sparsity:
Of the four possible combinations, dense+unweighted is silly because all pixels of the entire image, both the set and clear ones, vote the same. The accumulator array would look flat, except for boundary effects.
Dense is expensive, so people use sparse voting. Unweighted is cheaper to calculate, so people do that.
Canny is a way to binarize a picture and receive a very small set of pixels.
Canny will react to edges or gradients. OpenCV's Canny combines a gradient filter with the Canny-type ridge following filter. In theory, one could have just the Canny-type ridge following filter, and apply it to any image, without first getting a gradient map. Usually, people want the edges from a non-binary image (i.e. grayscale, single-channel or multi-channel), so getting the gradient map is a sensible step. Sometimes, you might already have that and you only want to enhance the ridges. Then you're out of luck.
For cv::HoughLines()
and cv::HoughLinesP()
, the input is assumed to be binarized, i.e. you need to ensure that or else the results will be strange. You can use Canny for that, or any other suitable method.
cv::HoughCircles()
always includes a Canny
step, so do not Canny the input explicitly in this case. I think the function does it like that to gain direction information from the gradient map.