Ask Your Question
0

Hough lines: minimum line length parameter not working?

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

Richard123 gravatar image

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

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 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2020-09-13 13:37:47 -0600

The problem is, do not use positional arguments. Use named arguments. I had the same problem. THere is some discrepancy in the parameters order in some versions and your minLenght is not being bound to any parameter.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-05-17 09:15:11 -0600

Seen: 3,955 times

Last updated: May 17 '18