我正在使用 the page 中的代码。它适用于我的大多数图像。但它在所附图像上失败 - 代码无法识别仪表的外表盘/边界(在我的原始图像中,没有内部白色圆圈)
知道可能出了什么问题吗?
最佳答案
这就是你所追求的吗...
如果是这样,那就是调整一些参数的问题。特别是最小和最大圆半径以及圆距离(检测到的圆之间的最小距离)。
要点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/