Python 霍夫变换不起作用
我正在尝试使用hough变换从图像中检测圆 我的代码:Python 霍夫变换不起作用,python,image,python-2.7,hough-transform,Python,Image,Python 2.7,Hough Transform,我正在尝试使用hough变换从图像中检测圆 我的代码: import numpy as np import cv2 image = cv2.imread("C:/Users/Anmol/Desktop/your_file.bmp") output = image.copy() gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY) circles = cv2.HoughCircles(gray, cv2.HOUGH_GRADIENT, 1.2,10)
import numpy as np
import cv2
image = cv2.imread("C:/Users/Anmol/Desktop/your_file.bmp")
output = image.copy()
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
circles = cv2.HoughCircles(gray, cv2.HOUGH_GRADIENT, 1.2,10)
cv2.waitKey(0)
print (circles)
# ensure at least some circles were found
if circles is not None:
# convert the (x, y) coordinates and radius of the circles to integers
circles = np.round(circles[0, :]).astype("int")
# loop over the (x, y) coordinates and radius of the circles
for (x, y, r) in circles:
# draw the circle in the output image, then draw a rectangle
# corresponding to the center of the circle
cv2.circle(output, (x, y), r, (0, 255, 0), 4)
cv2.rectangle(output, (x -5, y - 5), (x + 5, y + 5), (0, 128, 255), -1)
# show the output image
cv2.imshow("output", np.hstack([image, output]))
cv2.waitKey(0)
在终点站停车
circles = cv2.HoughCircles(gray, cv2.HOUGH_GRADIENT, 1.2,10)
我让我的代码运行了大约5个小时,但仍然没有超过这一行。它没有给出任何错误
Plzz指导我该怎么做。我建议,如果输入图像太大,则缩小其尺寸,并运行模糊过滤器。这两种方法都将极大地加快Hough的速度。如果您使用的是像PyCharm这样的IDE,您可以在该行设置断点,然后逐步遍历所有第三方代码,直到找到进度被阻止的确切位置。调试器仍然无法显示该步骤的内部情况。指向我的图像的链接是