RustamIS
RustamIS

Reputation: 697

Rotation of RotatedRect in OpenCv

I am using OpenCV in Java. I have two concerns, one of them is crucial for me:

I have RotatedRect and I want to Rotate this RotatedRect and get new RotatedRect or just Rect (in case of rotating strict vertical or horizontal). let it say:

RotatedRect rr = ...; //existing RotatedRect 
RotatedRect result = rotateRotatedRect(rr, angle);

I need smth for rotateRotatedRect() method.

My second question is, I want to scale RotatedRect (scaling from the center or from one of the corner is fine)

Can you suggest me anything. I can implement this, but requires time and logiic. Thank you.

Upvotes: 0

Views: 1195

Answers (1)

Berriel
Berriel

Reputation: 13601

As you can see in the documentation:

Class RotatedRect

  • double angle (the rotation angle in a clockwise direction)

  • Point center (the rectangle mass center)

  • Size size (width and height of the rectangle)

To achieve rotation and scaling, you can directly change the RotatedRect variables.

RotatedRect rr = ...; // existing RotatedRect 
rr.angle += 30;       // rotates 30 degrees clockwise
rr.size.width *= 2;   // scales width by 2
rr.size.height *= 2;  // scales height by 2

Upvotes: 1

Related Questions