总目标:建立VOC格式数据集类以及操作内置函数
github项目地址(附有使用说明书):
https://github.com/A-mockingbird/VOCtype-datasetOperation
Day2.统计数据集各类别标签数目和剪裁图像中标注框并保存
1.统计数据集各类别标签数目
使用之前写好的解析代码,对每个xml及xml中每个标注框信息遍历
记录不同类别出现的次数,并保存再字典中
def _Countobject(self, annofile=None):
"""
Count the label numbers of every class, and print it
Precondition: annofile-the direction of xml file
"""
if annofile == None:
annofile = self.dataset_anno
#获取数据集中全部xml文件解析数据
annoparse = self._ParseAnnos(annofile)
#建立空字典,用于存储
count = {}
#对存储每个xml文件标注信息的字典进行遍历
for anno in annoparse:
#对单个xml文件中每个标注框信息进行遍历