Get edge co-ordinates after edge detection (Canny)

后端 未结 2 668
情深已故
情深已故 2021-01-14 16:40

I have been working with OpenCV for a fairly short time, and have performed Canny Edge Detection on an image, and also performed dilation after that to further separate the

2条回答
  •  没有蜡笔的小新
    2021-01-14 17:25

    Just offering a second method - not guaranteed to work.

    • Step 1: extract connected component and their contours. This can be applied after the Canny Edge Detection step.
      • FindContours
    • Step 2: If the contours are fairly good approximation of a square, you can use their bounding box directly.
      • BoundingRect - if the rectangles are always upright (not rotated)
      • MinAreaRect - if the rectangles are rotated.

    The reason for the disclaimer is that it only works on very clean results, without any broken edges or gaps in the Canny edges, etc. If you need a more robust way of finding rectangles, Hough transform will be necessary.

提交回复
热议问题