Detecting quadrilateral shapes from random set of lines segments

在这里输入图像描述

the image attached is the output of Hough Transform of Opencv 2.4.2

Could you please advise me with the best algorithm to detect the best Quadrilateral (not always rectangular) shape from these line segments

even though some corners will reside outside the image boundaries, I still need to detect them

Many Thanks


Without having time to actually try this, I could image something like this:

  • Iterate over all the lines and calculate the slopes.
  • Sort the lines by their slopes
  • If two lines have a roughly similar slope, they are either parallel or the same line with a gap in it (eg the almost vertical lines on the left). To figure out which, calculate where they will intercept the x or y axis. If they intercept at the same point, they are the same line and should be merged into one line. If not, put them in a set of (roughly) parallel lines.
  • Compare each set of parallel lines with each other set, and calculate if they intersect (possibly off screen).
  • Apply some application-dependent criterium to pick the best.
  • The running time of this depends a lot on the number of detected lines and the number of sets of parallel lines. You could improve a bit by considering only lines with a minimum length, playing with the threshold for which lines are considered parallel, etc.

    链接地址: http://www.djcxy.com/p/79594.html

    上一篇: 从图像中提取鲁棒性线

    下一篇: 从任意一组线段中检测四边形形状