cv2.HoughCircles运行超过15分钟

时间:2019-01-15 15:18:19

标签: python-3.x hough-transform

此代码执行了19分钟。我在this图片上运行了这段代码。

import cv2
import numpy as np

img = cv2.imread('D:\\hough\\coins.jpg',0)
img = cv2.medianBlur(img,5)
cimg = cv2.cvtColor(img,cv2.COLOR_GRAY2BGR)

circles = cv2.HoughCircles(img,cv2.HOUGH_GRADIENT,1,20,
                            param1=50,param2=30,minRadius=0,maxRadius=0)

circles = np.uint16(np.around(circles))
for i in circles[0,:]:
    # draw the outer circle
    cv2.circle(cimg,(i[0],i[1]),i[2],(0,255,0),2)
    # draw the center of the circle
    cv2.circle(cimg,(i[0],i[1]),2,(0,0,255),3)

cv2.imwrite('detected circles.jpg', cimg)
cv2.imshow('detected circles',cimg)
cv2.waitKey(0)
cv2.destroyAllWindows()

我想要类似this的东西,这是我收到的输出: enter image description here

如何解决?

0 个答案:

没有答案