+
+def calc_rotation_matrix():
+ width, height = 800, 480
+
+ pivot = (width / 2, height / 2)
+ angle = 10
+ theta = radians(angle)
+
+ # The dimensions of the bounding box of the rotated rectangle
+ W = width * abs(cos(theta)) + height * abs(sin(theta))
+ H = width * abs(sin(theta)) + height * abs(cos(theta))
+
+ scale_factor = 1 / min(width / W, height / H)
+
+ mat = cv2.getRotationMatrix2D(pivot, angle, scale_factor)
+ mat = np.vstack([mat, [0, 0, 1]])
+
+ return mat.flatten()