# How to rotate yolo format bounding boxes after image rotate?

So I am currently adding rotation augmentation using python opencv as shown below to augment yolo format bounding boxes [x, y, h, w]. I have tried various approaches online, but am currently stuck. I know that I have to compute the center of the bounding box, but how do I rotate it after to align with the rotation ? I am not sure how to transform the bounding box values to accommodate for the rotation.

``````rotation_angle = np.random.uniform(-45, 45)
rotation_matrix = cv.getRotationMatrix2D((width / 2, height / 2), rotation_angle, 1)
img = cv.warpAffine(img, rotation_matrix, (width, height))
x, y, w, h = bounding_box
# bounding bbox centers should simply be x, y since x, y are bounding box centers in yolo format
cx = x
cy = y
``````

calculate the corners of your box, then apply the transformation to the corners, then draw the polygon?

Why cant we simply mat mul the height and width of the bounding box with the rotation matrix (cos, -sin, sin, cos) ? Since we rotate around the center of the image shoudnt the center of the bounding box be also the same ?

but do we? where is the origin?