-
-
Notifications
You must be signed in to change notification settings - Fork 912
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
interface: add Python utility for reading MVS scenes (#1069)
- Loading branch information
4CJ7T
authored
Oct 23, 2023
1 parent
95decea
commit ecd5dde
Showing
3 changed files
with
195 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
''' | ||
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters