Get edge co-ordinates after edge detection (Canny)

ぃ、小莉子 提交于 2019-12-01 08:56:58

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.
  • Step 2: If the contours are fairly good approximation of a square, you can use their bounding box directly.

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!