What is the easiest * correct * method for detecting rectangles in an image?

I am trying to think of a better method for detecting rectangles in an image.

My initial thought is to use Hough transform for strings and select combinations of lines in which you have two lines intersecting both the lower part and the upper part with the same two lines, but this is not enough.

Would use a corner detector along with the Hough transform work?

+6
source share
3 answers

Check out / samples / c / squares.c on your OpenCV distribution. This example shows a square detector, and this should be a pretty good start.

My answer here also applies.

+5
source

I do not think that at present there is a simple and reliable method for detecting rectangles in an image. You have to deal with many problems, such as rectangles that are not exactly rectangular, but only approximately, partial occlusions, changes in lighting, etc.

One possible direction is to segment the image, and then check how close each segment is to the rectangle. Since you cannot trust the segmentation algorithm, you can run it several times with different parameters.

Another direction is to try to parametrically fit the rectangle to the image so that the magnitude of the image gradient along the contour is maximized.

If you decide to work with a parametric approach, you will notice that although the trivial way to parameterize a rectangle is to arrange its four corners, which is 8 parameters, there are several other representations that require fewer parameters.

+3
source

There is a Hough extension that may be useful.
http://en.wikipedia.org/wiki/Generalised_Hough_transform

+1
source

Source: https://habr.com/ru/post/903805/


All Articles