OpenCV2-Python-Tutorials
OpenCV2-Python-Tutorials copied to clipboard
Hough Transform Example Code Does Not Produce the Plot Shown
The code example in py_houghlines.rst only plots the first line detected, not all the lines as shown in the "result" image.
This is not a big deal, but as a first time user caused me a bit of confusion.
The following should fix it:
for line in lines:
rho = line[0][0]
theta = line[0][1]
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))