1
我遇到一些麻煩cv2.Houghlines()顯示垂直線時,我相信真正適合應提供水平線。 這裏是我使用的代碼的片段:霍夫空間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)
這是輸入和輸出:我認爲這將是更容易提取出正在發生的事情,如果
可以查看霍夫空間圖像。 但是,文檔不提供如何顯示完整空間的信息。 如何顯示整個Hough變換空間? 我試圖將閾值降低到1,但沒有提供圖像。
這實際上非常類似於我的代碼sed,但結果非常糟糕。你可以看到我在問題中添加的結果。 – chase