【发布时间】:2016-09-26 09:46:46
【问题描述】:
当我认为真正的拟合应该提供水平线时,我在 cv2.Houghlines() 显示垂直线时遇到了一些问题。 这是我正在使用的代码片段:
rho_resoultion = 1
theta_resolution = np.pi/180
threshold = 200
lines = cv2.HoughLines(image, rho_resoultion, theta_resolution, threshold)
# print(lines)
for line in lines:
rho, theta = line[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(image,(x1,y1),(x2,y2),(255,255,255),1)
cv2.namedWindow('thing', cv2.WINDOW_NORMAL)
cv2.imshow("thing", image)
cv2.waitKey(0)
这是输入和输出:
我认为如果可以查看霍夫空间图像,提取正在发生的事情会更容易。 但是,该文档没有提供有关如何显示完整霍夫空间的信息。 如何显示整个霍夫变换空间? 我尝试将阈值降低到 1,但它没有提供图像。
【问题讨论】:
标签: opencv computer-vision transform hough-transform