Exemplo n.º 1
0
def countObj(path):
    boxes = XML.read_object(path)
    return (len(boxes))
Exemplo n.º 2
0
 augNameList=['close','cover','open']
 xmlDir=r"/DATACENTER2/yh/detectron/caffe2/train/safebox/faster_voc/11469/xml_1713"
 tarDir=r"/DATACENTER2/yh/detectron/caffe2/train/safebox/faster_voc/11469/xml_1713_aug"
 FILES.mkdir(tarDir)
 allXmls=[x for x in FILES.get_sorted_files(xmlDir) if ".xml" in x]
 cur=0
 bgn=800 #包含
 end=1900 #包含
 for xml in allXmls:
     cur+=1
     # print(cur) #第cur个文件
     if cur>=bgn and cur<=end:
         xmlPath=xmlDir+'/'+xml
         tarXmlPath=tarDir+'/'+xml
         shutil.copy(xmlPath,tarXmlPath)
         BBOXES=XML.read_object(xmlPath)
         for augRate_xmin in range(0,5):
             augValue_xmin=augRate_xmin*0.02
             for augRate_xmax in range(0,5):
                 augValue_xmax=augRate_xmax*0.02
                 for augRate_ymin in range(0,5):
                     augValue_ymin=augRate_ymin*0.02
                     for augRate_ymax in range(0,5):
                         augValue_ymax=augRate_ymax*0.02
                         if augRate_xmin+augRate_xmax+augRate_ymin+augRate_ymax!=0:
                             bboxes=[]
                             for i in range(len(BBOXES)):
                                 if BBOXES[i][0] in augNameList and check_overlap(BBOXES[i],BBOXES):
                                     bboxes.append(trans_box(BBOXES[i],augValue_xmin,augValue_ymin,augValue_xmax,augValue_ymax))
                             try:
                                 add_box(tarXmlPath,bboxes)
Exemplo n.º 3
0
def checkName(path, name):
    boxes = XML.read_object(path)
    for box in boxes:
        if box[0] == name:
            return 1
    return 0