-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathproject-getoutput.py
30 lines (23 loc) · 1.07 KB
/
project-getoutput.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
import imageio
import numpy
import argparse
import os, shutil
parser = argparse.ArgumentParser(description='Process some integers.')
parser.add_argument('--project', metavar='dir', type=str,
help='Project directory', required=True)
parser.add_argument('--output', metavar='file', type=str,
help='Output base name', required=True)
args = parser.parse_args()
#Copy texture
shutil.copy(os.path.join(args.project,'openmvs','model_dense_mesh_refine_texture.png'), args.output+'.png')
#Copy file, updating texture name
in_data = open(os.path.join(args.project,'openmvs','model_dense_mesh_refine_texture.ply'), 'rb').read()
out_file = open(args.output+'.ply', 'wb')
end_header_position = in_data.index(b'end_header') + 10
header_data = in_data[:end_header_position].decode('ascii')
for line in header_data.split('\n'):
if line.startswith('comment TextureFile'):
line = 'comment TextureFile ' + os.path.basename(args.output)
out_file.write(line.encode('ascii')+b'\n')
out_file.write(in_data[end_header_position+1:])
out_file.close()