【发布时间】:2019-01-14 20:10:30
【问题描述】:
我正在尝试使用霍夫线过滤图像,但有些东西不起作用。
我创建了以下子例程,它是从文档中复制粘贴而没有修改:
def FilterLines(img):
lines = cv2.HoughLines(img,1,np.pi/180,200)
blank_image = np.zeros((img.shape[0], img.shape[1]), np.uint8)
if (lines is None):
return blank_image
for rho,theta in lines[0]:
a = np.cos(theta)
b = np.sin(theta)
x0 = a*rho
y0 = b*rho
x1 = int(x0 + 1000*(-b))
y1 = int(y0 + 1000*(a))
x2 = int(x0 - 1000*(-b))
y2 = int(y0 - 1000*(a))
cv2.line(blank_image,(x1,y1),(x2,y2),255,1)
return blank_image
所以它在底部检测到几行,没有别的。
为什么函数不能在如此简单的图像中检测线条?
【问题讨论】:
标签: python opencv image-processing hough-transform