opencv - LINUX opencv霍夫变换圆

标签 opencv geometry hough-transform

我正在使用 the page 中的代码。它适用于我的大多数图像。但它在所附图像上失败 - 代码无法识别仪表的外表盘/边界(在我的原始图像中,没有内部白色圆圈)enter image description here

知道可能出了什么问题吗?

最佳答案

这就是你所追求的吗...

enter image description here

如果是这样,那就是调整一些参数的问题。特别是最小和最大圆半径以及圆距离(检测到的圆之间的最小距离)。

要点here .

更新
如果你想将最小半径与图像尺寸联系起来,你可以这样做:

float minRadius = MIN(img.size().width, img.size().height) * 0.5;

并将其提供给 houghCircles 函数。

我实际使用的参数(根据要点):

 HoughCircles(     img
                 , circles
                 , CV_HOUGH_GRADIENT //method – Detection method to use. 
                 // Currently,  the only implemented method is 
                 // CV_HOUGH_GRADIENT , which is  basically 21HT , 
                 // described in [Yuen90].
                 , 1 //p – Inverse ratio of the accumulator resolution to the 
                 // image resolution. For example, if dp=1 , the accumulator has 
                 // the same resolution as the input image. If dp=2 , 
                 // the accumulator has half as big width and height.
                 , 60  //minDist – Minimum distance between the centers of the 
                 // detected circles. If the parameter is too small, multiple 
                 // neighbor circles may be falsely detected in addition to a 
                 // true one. If it is too large, some circles may be missed.
                 , 100 //cannyThreshold – The higher threshold of the two 
                 // passed  to the gpu::Canny() edge detector 
                 // (the lower one is twice smaller).
                 , 30 //votesThreshold – The accumulator threshold for the circle 
                 // centers at the detection stage. The smaller it is, the more 
                 // false circles may be detected.
                 , 250 //minRadius – Minimum circle radius.
                 , 300 //maxRadius – Maximum circle radius.
                 );

评论已从 openCV documentation 中删除.

关于opencv - LINUX opencv霍夫变换圆,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31689949/

相关文章:

algorithm - 给定一组格点,有多少组点?

opencv - 广义霍夫变换 OpenCV Python 模板

opencv - matchTemplate 与 openCV 在 Java 中

python-3.x - OpenCV 无法打开 *.mp4 文件

python - 如何将 cv2 处理后的图像保存到 Django 模型中?

opencv - 使用Hough变换OpenCV Android进行矩形文档检测

c++ - cvHoughLines2 内存泄漏

opencv - opencv中的内存泄漏问题

c++ - 线段球体相交测试c++

javascript - 如何保持半圆外线上两点之间的距离相同?