OpenCV: Preventing the HoughCircles Method Using Canny Detection

I use HoughCircles to detect the ball in real time, but running Canny on my gray scale image stream does not create all the faces as it should. To fix this, I split the rgb image into separate channels, executing Canny on each of them, then using bitwise or combining edges together. This works very well, but if I submit this image to HoughCircles, it will execute Canny again on the edge image. Is there a way to prevent this or to refuse detection of Canny's RGB bit, which I execute while preserving all edges?

+7
c ++ opencv object-detection edge-detection hough-transform
source share
1 answer

Really ! Canny is executed inside HoughCircles , and there is no way to call cv::HoughCircles() and prevent it from calling Canny.

However , if you want to stick with your current approach, one option is to copy the version of cv::HoughCircles() available in the OpenCV source code and change it to suit your needs. This will allow you to write your own version of cv::HoughCircles() .

If you are following this path, it is important to understand that the C ++ API of OpenCV is built on the C API. This means that cv::HoughCircles() is just a wrapper around cvHoughCircles() , which is implemented in opencv-2.4.7/modules/imgproc/src/hough.cpp after line 1006.

Look at this function (line 1006) and notice the call made using icvHoughCirclesGradient() on line 1064. This is the function responsible for calling cvCanny() , which is executed on line 817.

Another approach, if the ball is monochrome , can be implemented using cv::inRange() to isolate a specific color , and this will provide much faster detection. In addition, this issue has been widely discussed at this forum. Very interesting topic:

  • Writing reliable (color and dimensional) circle detection using OpenCV (based on Hough Transform transform or other functions)
+10
source share

All Articles