在OpenCV 3.4.2中,添加了返回HoughLines()返回的每一行的投票数(累加器值)的选项.在python中,似乎支持以及在我的OpenCV安装的python docstring中读取:
"每条线由2或3个元素向量(ρ,θ)或(ρ,θ,votes)表示."
它也包含在文档中(有一些破碎的格式). 但是我找不到在python中返回3元素选项(ρ,θ,votes)的方法. 以下是演示此问题的代码:
import numpy as np
import cv2
print('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)
Run Code Online (Sandbox Code Playgroud)
输出
OpenCV should be at least 3.4.2 to test: 3.4.2
(number of lines, 1, output vector dimension): (3, 1, …Run Code Online (Sandbox Code Playgroud)