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

おすすめ

転載: blog.csdn.net/qq_40107571/article/details/134701009