Get edge co-ordinates after edge detection (Canny)

后端 未结 2 655
情深已故
情深已故 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:22

    You could use the corner detectors provided in OpenCV like Harris or Corner Eigenvalues. Here's an example of that along with full-fledged code.

    In case other features are also throwing up corners you may need to go in for connected component analysis.

    0 讨论(0)
  • 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.

    0 讨论(0)
提交回复
热议问题