Hough lines: minimum line length parameter not working?

asked 2018-05-17 09:15:11 -0500

Richard123 gravatar image

updated 2018-05-17 09:15:45 -0500

I am trying to detect right-angle corners with Hough Line. Unfortunately, I can't work out how to get the minimum line length setting to do anything.

Here is my original image:

image description

Here are the canny edges:

image description

And here are the detected Hough lines. No matter what I change the min line length parameter to, all the lines still appear, including the tiny ones.

image description

This is my code:

gray = cv2.cvtColor(corner_img, cv2.COLOR_BGR2GRAY)
edges = cv2.Canny(gray, 100, 200)
cv2.imwrite('cropped_sw_corner-canny.png', edges)
minLineLength = 10 # Changing this to 100 does nothing.
maxLineGap = 1
threshold = 100
lines = cv2.HoughLinesP(edges,1,np.pi/180,threshold,minLineLength,maxLineGap)
for l in lines:
    for x1,y1,x2,y2 in l:
        cv2.line(corner_img,(x1,y1),(x2,y2),(0,0,255), 2)
cv2.imwrite('houghlines.jpg', corner_img)

I'm using OpenCV 3.4.0.14 on OSX with Python 2.7.

edit retag flag offensive close merge delete

Comments

Answer here https://stackoverflow.com/a/35795567/... (I'm too new to post an answer)

Richard123 gravatar imageRichard123 ( 2018-05-17 10:37:04 -0500 )edit