因为原来标好的数据集的图片太大,需要进行裁剪,但又不想重新进行标注,所以用一个python小程序进行裁剪图片并同步框的坐标。(我的数据集只有一类,所以只用遍历所有的bndbox)这个能裁出4个300*300的图片,基本上能用,第一次写python,在别人的基础上改的...
from __future__ import division
import os
from PIL import Image
import xml.dom.minidom
import numpy as np
ImgPath = 'C:/Users/yaoyao/Desktop/XML_try/img/'
AnnoPath = 'C:/Users/yaoyao/Desktop/XML_try/xml/'
ProcessedPath = 'C:/Users/yaoyao/Desktop/pic/'
prefix_str = '''<annotation>
<folder>HollywoodHeads</folder>
<filename>{}.jpeg</filename>
<source>
<database>HollywoodHeads 2015 Database</database>
<annotation>HollywoodHeads 2015</annotation>
<image>WILLOW</image>
</source>
<size>
<width>1171</width>
<height>647</height>
<depth>3</depth>
</