目录
图像绕中心点旋转,图像保持完整,旋转后会增大,点也一起旋转:
#点p_x, p_y 围绕center_x, center_y顺时针旋转angle度
图像绕中心点旋转,box一起旋转,获取旋转后的外接矩形框。
import numpy as np
import argparse
import cv2
# 旋转后图像完整,图像会增大
def rotate_bound(image, angle, box_points):
(h, w) = image.shape[:2]
(cX, cY) = (w // 2, h // 2)
# angle to rotate clockwise), then grab the sine and cosine
# (i.e., the rotation components of the matrix)
rot_mat = cv2.getRotationMatrix2D((cX, cY), -angle, 1.0)
cos = np.abs(rot_mat[0, 0])
sin = np.abs(rot_mat[0, 1])
# comp