-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
61 lines (56 loc) · 1.95 KB
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# -*- coding: utf-8 -*-
"""
Created on Thu Jun 13 13:47:51 2019
@author: budefei
"""
import os
import os.path
import xml.dom.minidom
from xml.dom.minidom import parse
import xml.dom.minidom
import os,shutil
import numpy as np
import cv2
from PIL import Image, ImageDraw
path="/data_1/ssd-project/SSD_data_augment/1_xml"
files=os.listdir(path)
s=[]
k=0
for xmlFile in files:
k=k+1
print k
print xmlFile
if not os.path.isdir(xmlFile):
#print xmlFile
dom=xml.dom.minidom.parse(os.path.join(path,xmlFile))
root=dom.documentElement
objects = root.getElementsByTagName("object")
for object_ in objects:
a=object_.getElementsByTagName("name")[0].childNodes[0].nodeValue
if a=="chebiao11":
print xmlFile
#name=object_.getElementsByTagName('name')
#n0=name[0]
#n0.firstChild.data='chebiao11'
name0=object_.getElementsByTagName('xmin')
n0=name0[0]
n0.firstChild.data='121'
#xmin_val=n0.firstChild.data
#ymin
ymin_name=object_.getElementsByTagName("ymin")[0].childNodes[0].nodeValue
name1=object_.getElementsByTagName('ymin')
n1=name1[0]
#ymin_val=n1.firstChild.data
#xmax
xmax_name=object_.getElementsByTagName("xmax")[0].childNodes[0].nodeValue
name2=object_.getElementsByTagName('xmax')
n2=name2[0]
#xmax_val=n2.firstChild.data
#ymax
ymax_name=object_.getElementsByTagName("ymax")[0].childNodes[0].nodeValue
name3=object_.getElementsByTagName('ymax')
n3=name3[0]
ymax_val=n3.firstChild.data
n3.firstChild.data='11'
with open(os.path.join(path, xmlFile), 'w') as fh:
dom.writexml(fh)