0

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.

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

2 Comments

Thank you. I've just looked for source code, and you are right! I haven't thought it might be like this. I was expecting calculation on native level.
@RustamIS :) You can move (translate) the RotatedRect by moving the center too.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.