Ask Your Question
0

How to detect concentric squares?

asked 2014-09-22 06:04:08 -0600

Victor1234 gravatar image

updated 2014-09-22 07:29:26 -0600

I have vector of approximated 4-point closed contours. How I can determine that some of them are concentric? image description

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2014-09-22 07:47:27 -0600

thdrksdfthmn gravatar image

The way to go I thing is using minAreaRect function that returns a RotatedRect that has a centre. Based on the distance between the centres, you can define an error of "concentricity" of the two or more rectangles.

edit flag offensive delete link more

Comments

I througth about it. But if view angle is too big squares turn into quads and can not be decribed by RotatedRect. But I'll try and let you know.

Victor1234 gravatar imageVictor1234 ( 2014-09-22 08:03:47 -0600 )edit

you have also fitEllipse, but it returns RotatedRect too. (Anyway, what do you mean by quad?)

thdrksdfthmn gravatar imagethdrksdfthmn ( 2014-09-22 08:20:42 -0600 )edit

Worked well for me! To compare whether two contours are nested, and to find the biggest one:

  • minAreaRect(); for both contours
  • pointPolygonTest() for each contour and the other contour's center
  • If the signs of both pointPolygonTest() calls are positive, they are concentric
  • the outermost contour has the largest area, compute with contourArea()
pibbs gravatar imagepibbs ( 2017-04-12 19:49:08 -0600 )edit

Question Tools

Stats

Asked: 2014-09-22 06:04:08 -0600

Seen: 636 times

Last updated: Sep 22 '14