Skip to content
Advertisement

Rotate polygons without cutting edges

I am writing an augmentation code to rotate annotated polygons inside images. I wrote a code but it’s not working right. Just Copy paste the code and you can get the results. Thank you for helping me out.

Image:

enter image description here

Need to rotate the image as well as a polygon for respective angle. Currently, I am not able to rotate the polygon

enter image description here

The image is rotated but the polygon is still in its place.

I tried This code. It rotates the polygon but not at the right position

JavaScript

Advertisement

Answer

Rotation equations are:

JavaScript

only mistake you are doing is this:

JavaScript

After rotating image, cx and cy should be changed

Your complete code is as below:

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement