在 OpenCV 3.4.2 中,添加了為 HoughLines() 返回的每一行返回投票數(累加器值)的選項。在 python 中,這似乎得到支持,也可以在我的 OpenCV 安裝的 python 文檔字符串中讀?。骸懊啃杏梢粋€ 2 或 3 個元素的向量 ( ρ , θ ) 或 ( ρ , θ ,投票) 表示。”它也包含在文檔中(具有一些損壞的格式)。 但是我找不到在 python 中返回 3 元素選項(ρ、θ、votes)的方法。 這是演示問題的代碼:import numpy as npimport cv2print('OpenCV should be at least 3.4.2 to test: ', cv2.__version__)image = np.eye(10, dtype='uint8')lines = cv2.HoughLines(image, 1, np.pi/180, 5)print('(number of lines, 1, output vector dimension): ', lines.shape)print(lines)產出OpenCV should be at least 3.4.2 to test: 3.4.2(number of lines, 1, output vector dimension): (3, 1, 2)[[[ 0. 2.3212879]] [[ 1. 2.2340214]] [[-1. 2.4609141]]]所需的行為是一個額外的列,其中包含每行收到的票數。有了投票值,可以應用比標準閾值更高級的選項,因此經常在 SE(這里、這里、這里和這里)上請求和詢問它,有時與 HoughCircles() 等效。但是問題和答案(如修改源和重新編譯)都是在正式添加之前的,因此不適用于當前情況。
OpenCV+python:從 3.4.2 開始訪問 HoughLines 累加器
慕田峪7331174
2021-06-11 10:02:15