Create a box the bounds them into smallest possible box.

asked 2015-04-29 04:46:46 -0500

215 gravatar image

Hi guys.. I am trying to bound some points into a box (Rect).. The problem is though the box becomes to large, even though I use boundingRect..

I am trying to box the features The sample code Surf detect on a image.

Code can be seen here.

I want to retract the green square to a rect.

edit retag flag offensive close merge delete



Have you considered to use rotatedRect?

LorenaGdL gravatar imageLorenaGdL ( 2015-04-29 05:20:05 -0500 )edit

If the rotatedRect does not satisfies you, maybe boundingRect does (even it seems that the first one is much closer from your description)?

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-04-29 06:30:14 -0500 )edit

I tried both.. and they do not work..

215 gravatar image215 ( 2015-04-29 06:45:07 -0500 )edit

What? how did you tried them? They are not present in the posted code, just add that part

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-04-29 06:46:46 -0500 )edit

I think it's pretty obvious, but a Rectangle does not only contain 4 sides but also four 90ยบ angles. Therefore you can never get the exact same green box encapsulated in a Rect structure. Obviously, both rotatedRect and boundingRect will produce rectangles bigger than the green box

LorenaGdL gravatar imageLorenaGdL ( 2015-04-29 06:55:58 -0500 )edit

They work but the issue is they create a area that is too big compared to the points..

215 gravatar image215 ( 2015-04-29 07:00:07 -0500 )edit

If you post your code and some images of the output, we'd probably understand the problem better

LorenaGdL gravatar imageLorenaGdL ( 2015-04-29 07:27:20 -0500 )edit

Do you want to encapsulate just the matches or the whole object?

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-04-29 09:00:09 -0500 )edit

Just the matches..

215 gravatar image215 ( 2015-04-29 09:14:34 -0500 )edit

minAreaRect should do it, but the input should be obj

thdrksdfthmn gravatar imagethdrksdfthmn ( 2015-04-29 09:18:15 -0500 )edit