-
Notifications
You must be signed in to change notification settings - Fork 0
/
transform_pts.py
executable file
·37 lines (35 loc) · 1.56 KB
/
transform_pts.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
if __name__ == '__main__':
for n in range(1, 11):
filename_w = '{0:06d}.pts'.format(n)
filename_r = '{0:06d}_.pts'.format(n)
with open('/root/datasets/madomagi/madomagi_face_tmp/homura/' + filename_w, 'w') as file_w:
try:
with open('/root/datasets/madomagi/madomagi_face_tmp/homura/' + filename_r, 'r') as file_r:
# header
file_w.write('version: 1\n')
file_w.write('n_points: 68\n')
file_w.write('{\n')
for i in range(2):
file_r.readline()
# contour & brow
for i in range(27):
file_w.write(file_r.readline().replace('\t', ' '))
# nose
nose = file_r.readline().replace('\t', ' ')
for i in range(9):
file_w.write(nose)
# eye
for i in range(12):
file_w.write(file_r.readline().replace('\t', ' '))
# lip
lips = []
for i in range(12):
lip = file_r.readline().replace('\t', ' ')
file_w.write(lip)
lips.append(lip)
lip_no_list = [0, 2, 3, 4, 6, 8, 9, 10]
for i in lip_no_list:
file_w.write(lips[i])
file_w.write('}\n')
except IOError:
print('file is nothing')