user654972
user654972

Reputation: 31

Get edge co-ordinates after edge detection (Canny)

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 object (in my case a square) from the background.

My problem, now is to identify graspable regions in 2D using an algorithm that requires me to handle co-ordinates of the points in those edges. Is there any way I can use OpenCV to get the co-ordinates of the corners so I can find the equation of the lines forming the edge of the square? I know the size of the square. My problem involves 2D co-ordinate geometry, and hence the need for co-ordinates.

I can provide the image after edge detection and dilation if need be. Help would be appreciated a lot.

Upvotes: 3

Views: 5377

Answers (2)

rwong
rwong

Reputation: 6162

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.

Upvotes: 3

AruniRC
AruniRC

Reputation: 5148

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.

Upvotes: 1

Related Questions