(python)opencv找圆cv2.houghCircles()

关于函数参数输入输出:

cv2.HoughCircles(image, method, dp, minDist, circles, param1, param2, minRadius, maxRadius) 

这个时候输入为灰度图像,同时最好规定检测的圆的最大最小半径,不能盲目的检测,否侧浪费时间空间。输出就是三个参数空间矩阵。

circles1 = cv2.HoughCircles(gray,cv2.HOUGH_GRADIENT,1,
100,param1=100,param2=30,minRadius=200,maxRadius=300)


#第一个参数
一个灰度图


#第二个参数method
使用的检测方法 写这个即可


#第三个参数dp
用来检测内侧圆心的累加器图像的分辨率于输入图像之比的倒数。
如dp=1,累加器和输入图像具有相同的分辨率,如果dp=2,累计器便有输入图像一半那么大的宽度和高度


#第四个参数minDist
为霍夫变换检测到的圆的圆心之间的最小距离,即让算法能明显区分的两个不同圆之间的最小距离。
如果这个参数太小,多个相邻的圆可能被错误的检测成了一个重合的圆,反之,参数设置太大,某些圆就不能被检测出来


#第五个参数param1
有默认值100,它是method设置的检测方法的对应的参数,对当前唯一的方法霍夫梯度法cv2.HOUGH_GRADIENT,它表示传递给canny边缘检测算子的高阈值,而低阈值为高阈值的一半


#第六个参数param2
有默认值100,它是method设置的检测方法的对应的参数,对当前唯一的方法霍夫梯度法cv2.HOUGH_GRADIENT,它表示在检测阶段圆心的累加器阈值,它越小,就越可以检测到更多根本不存在的圆,而它越大的话,能通过检测的圆就更加接近完美的圆形了。


#第七个参数minRadius
有默认值0,圆半径的最小值
#第八个参数maxRadius
有默认值0,圆半径的最大值


参考 电子工业出版社《OpenCV3编程入门》

-----------------------------------------------2017.6.14-------------------------------------------

•image: 8-bit, single channel image. If working with a color image, convert to grayscale first.
•method: Defines the method to detect circles in images. Currently, the only implemented method is cv2.HOUGH_GRADIENT, which corresponds to the Yuen et al. paper.
•dp: This parameter is the inverse ratio of the accumulator resolution to the image resolution (see Yuen et al. for more details). Essentially, the larger the dp gets, the smaller the accumulator array gets.
•minDist: Minimum distance between the center (x, y) coordinates of detected circles. If the minDist is too small, multiple circles in the same neighborhood as the original may be (falsely) detected. If the minDist is too large, then some circles may not be detected at all.
•param1: Gradient value used to handle edge detection in the Yuen et al. method.
•param2: Accumulator threshold value for the cv2.HOUGH_GRADIENT method. The smaller the threshold is, the more circles will be detected (including false circles). The larger the threshold is, the more circles will potentially be returned.
•minRadius: Minimum size of the radius (in pixels).
•maxRadius: Maximum size of the radius (in pixels).

http://www.pyimagesearch.com/2014/07/21/detecting-circles-images-using-opencv-hough-circles/

  • 6
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值