How to detect lines in OpenCV?

前端 未结 4 1301
一整个雨季
一整个雨季 2020-11-28 03:46

I am trying to detect lines in parking as shown below.

What I hope to get is the clear lines and (x,y) position in the crossed line. However, the result is no

4条回答
  •  难免孤独
    2020-11-28 04:26

    what happens if you adjust maxLineGap or size of your erosion kernel. Alternatively, you could find the distance between lines. You would have to go though pairs of lines say ax1,ay1 to ax2,ay2 c.f. bx1,by1 to bx2,by2 you can find the point where the gradient at right angles (-1 over gradient of line) to a crosses line b. Basic school geometry and simultaneous equations, something like:

    x = (ay1 - by1) / ((by2 - by1) / (bx2 - bx1) + (ax2 - ax1) / (ay2 - ay1))
    # then
    y = by1 + x * (by2 - by1) / (bx2 - bx1)
    

    and compare x,y with ax1,ay1

    PS you might need to add a check for the distance between ax1,ay1 and bx1,by1 as some of your lines look to be continuations of other lines and these might be eliminated by the closest point technique.

提交回复
热议问题