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