I\'m trying to get the same result they got in this tutorial for HoughLinesP filter. I took same images and same threshold values like this :
import cv2
fro
As Dan's answer mentions, the arguments are not correctly specified in Canny and HoughLinesP.
Modified code:
import cv2
from line import Line
import numpy as np
img = cv2.imread('building.jpg',1)
cannied = cv2.Canny(img, 50, 200, apertureSize=3)
lines = cv2.HoughLinesP(cannied, 1, np.pi / 180, 80, minLineLength=30, maxLineGap=10)
for leftx, boty, rightx, topy in lines[0]:
line = Line((leftx, boty), (rightx,topy))
line.draw(img, (255, 255, 0), 2)
cv2.imwrite('lines.png',img)
cv2.imwrite('canniedHouse.png',cannied)
cv2.waitKey(0)
cv2.destroyAllWindows()
Output:
If you are using OpenCV-3+, use this for-loop instead since HoughLinesP returns a different output format [[[x1, y1, x2, y2]], [[...]]...[[...]]]
for l in lines: #Modified to loop across all the lines
leftx, boty, rightx, topy = l[0] #assign each line's values to variables
line = Line((leftx, boty), (rightx,topy))
line.draw(img, (255, 255, 0), 2)