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