voc边框坐标旋转变换

import os
import xml.etree.ElementTree as ET
import cv2
import numpy as np
from matplotlib import pyplot as plt
ann=os.listdir('./Annotations')

for _ in ann:
    path=os.path.join('./Annotations',_)
    tree=ET.parse(path)
    root=tree.getroot()

    image_name=root.find('filename').text
    image_path=os.path.join('./JPEGImages',image_name)
    image=cv2.imread(image_path)
    rows,cols,_=image.shape

    obj=root.find('object')
    xmlbox = obj.find('bndbox')  # 读取标注信息 [xmin,ymin,xmax,yamx]
    b1 = (int(float(xmlbox.find('xmin').text)), int(float(xmlbox.find('ymin').text)),
         int(float(xmlbox.find('xmax').text)), int(float(xmlbox.find('ymax').text)))

    center=[cols/2, rows/2]
    for _ in [0,90,180,270]:
        # image1=np.rot90(image,_).copy()
        M = cv2.getRotationMatrix2D((cols/2, rows/2), _, 1

你可能感兴趣的:(目标检测,numpy,opencv,人工智能)