首页 > 解决方案 > 无霍夫圆检测

问题描述

我已经使用 Circle Hough 变换来检测此图像中的圆圈,通过在 python 中使用此代码,但现在我想通过使用另一种方法来检测圆圈,除了圆圈 Hough 变换之外,还有其他方法可以检测圆圈吗


import cv2
import numpy as np

img = cv2.imread("Resources/coin0.jpg")
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
blur= cv2.medianBlur(gray, 5)
# center


dp=1.1
minDis=10
param1=150
param2=40
minRadius=0
maxRadius=0

circles = cv2.HoughCircles(blur, cv2.HOUGH_GRADIENT, dp, minDis,
                        param1 =param1, param2 =param2, minRadius = minRadius, maxRadius = maxRadius)

circles = np.uint16(np.around(circles))
for i in circles[0, :]: ## Draw circle on the circles

 #  draw   the    outer  circle
 cv2.circle(img, (i[0], i[1]), i[2], (0, 255, 0),2)
 #  draw   the    center of the    circle
 cv2.circle(img, (i[0], i[1]), 2, (0, 0, 255),2)





cv2.imshow("Image",img)
cv2.waitKey(0)
cv2.destroyAllWindows()



在此处输入图像描述

标签: pythonopencvdetection

解决方案


推荐阅读