Create a box the bounds them into smallest possible box.

asked Apr 29 '15

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.

http://docs.opencv.org/doc/tutorials/...

I want to retract the green square to a rect.

Preview: (hide)

Comments

1

Have you considered to use rotatedRect?

LorenaGdL gravatar imageLorenaGdL (Apr 29 '15)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 (Apr 29 '15)edit

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

215 gravatar image215 (Apr 29 '15)edit

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

thdrksdfthmn gravatar imagethdrksdfthmn (Apr 29 '15)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 (Apr 29 '15)edit

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

215 gravatar image215 (Apr 29 '15)edit
3

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

LorenaGdL gravatar imageLorenaGdL (Apr 29 '15)edit

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

thdrksdfthmn gravatar imagethdrksdfthmn (Apr 29 '15)edit

Just the matches..

215 gravatar image215 (Apr 29 '15)edit

minAreaRect should do it, but the input should be obj

thdrksdfthmn gravatar imagethdrksdfthmn (Apr 29 '15)edit