Skip to content

Commit 15ab4be

Browse files
committed
update ch26
1 parent e11864f commit 15ab4be

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

ch26-Hough圆环变换/HoughCircles.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
__author__ = 'play4fun'
33
"""
44
create time:15-10-25 下午12:02
5+
一个圆环 需要 3 个参数来确定。所以进行圆环 夫变换的累加器必须是 3 维的
6+
这样的 效率 就会很低。所以 OpenCV 用来一个比 巧妙的办法 霍夫梯度法 它可以使 用边界的梯度信息。
57
"""
68

79
import cv2
@@ -12,6 +14,7 @@
1214
cimg = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR)
1315

1416
circles = cv2.HoughCircles(img, cv2.HOUGH_GRADIENT, 1, 20, param1=50, param2=30, minRadius=0, maxRadius=0)
17+
1518
circles = np.uint16(np.around(circles))
1619
print(circles)
1720

@@ -20,6 +23,7 @@
2023
cv2.circle(cimg, (i[0], i[1]), i[2], (0, 255, 0), 2)
2124
# draw the center of the circle
2225
cv2.circle(cimg, (i[0], i[1]), 2, (0, 0, 255), 3)
26+
2327
cv2.imshow('detected circles', cimg)
2428
cv2.waitKey(0)
2529
cv2.destroyAllWindows()

0 commit comments

Comments
 (0)