1、原始状态
最初的图像是这个样子的
.xml文件张下面这个样子
<annotation>
<object>
<name>face</name>
<difficult>0</difficult>
<bndbox>
<xmin>315.307918</xmin>
<ymin>240.234604</ymin>
<xmax>693.677419</xmax>
<ymax>699.683284</ymax>
</bndbox>
</object>
</annotation>
2、旋转图像并修改对应的xml文件
import cv2
import math
import numpy as np
import os
# pdb仅仅用于调试,不用管它
import pdb
#旋转图像的函数
def rotate_image(src, angle, scale=1.):
w = src.shape[1]
h = src.shape[0]
# 角度变弧度
rangle = np.deg2rad(angle) # angle in radians
# now calculate new image width and height
nw = (abs(np.sin(rangle)*h) + abs(n