gpt4 book ai didi

opencv - LINUX opencv霍夫变换圆

转载 作者:太空宇宙 更新时间:2023-11-03 21:35:30 25 4
gpt4 key购买 nike

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

知道哪里出了问题吗?

最佳答案

这就是你想要的...

enter image description here

如果是这样,那就是调整一些参数的问题。特别是最小和最大圆半径以及 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 中删除的.

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

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com