-
-
Notifications
You must be signed in to change notification settings - Fork 983
Expand file tree
/
Copy pathMvsReadMVS.py
More file actions
37 lines (29 loc) · 1.28 KB
/
Copy pathMvsReadMVS.py
File metadata and controls
37 lines (29 loc) · 1.28 KB
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
#!/usr/bin/python3
# -*- encoding: utf-8 -*-
'''
Example usage of MvsUtils.py for reading MVS interface archive content.
usage: MvsReadMVS.py [-h] [--input INPUT] [--output OUTPUT]
'''
from argparse import ArgumentParser
import json
from MvsUtils import loadMVSInterface
import os
def main():
parser = ArgumentParser()
parser.add_argument('-i', '--input', type=str, required=True, help='Path to the MVS interface archive')
parser.add_argument('-o', '--output', type=str, required=True, help='Path to the output json file')
args = parser.parse_args()
mvs = loadMVSInterface(args.input)
for platform_index in range(len(mvs['platforms'])):
for camera_index in range(len(mvs['platforms'][platform_index]['cameras'])):
camera = mvs['platforms'][platform_index]['cameras'][camera_index]
image_max = max(camera['width'], camera['height'])
fx = camera['K'][0][0] / image_max
fy = camera['K'][1][1] / image_max
poses_size = len(camera['poses'])
print('Camera model loaded: platform {}; camera {}; f {:.3f}x{:.3f}; poses {}'.format(platform_index, camera_index, fx, fy, poses_size))
os.makedirs(os.path.dirname(args.output), exist_ok = True)
with open(args.output, 'w') as file:
json.dump(mvs, file, indent=2)
if __name__ == '__main__':
main()