同步缩放图片(等比例缩放无失真)和xml文件标注的anchor size
import glob
import xml.dom.minidom
import cv2
from PIL import Image
import matplotlib.pyplot as plt
import os
# 定义待批量裁剪图像的路径地址
IMAGE_INPUT_PATH = r'D:\code\data\JPEGImages'
XML_INPUT_PATH = r'D:\code\data\Annotations_new'
# 定义裁剪后的图像存放地址
IMAGE_OUTPUT_PATH = r'D:\code\data\JPEGImages_out'
XML_OUTPUT_PATH = r'D:\code\data\Annotations_out'
imglist = os.listdir(IMAGE_INPUT_PATH)
xmllist = os.listdir(XML_INPUT_PATH)
for i in range(len(imglist)):
# 每个图像全路径
image_input_fullname = IMAGE_INPUT_PATH + '/' + imglist[i]
xml_input_fullname = XML_INPUT_PATH + '/' + xmllist[i]
image