-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathapp.py
67 lines (51 loc) · 2.05 KB
/
app.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
62
63
64
65
66
67
import os, sys
import argparse
import numpy as np
from src.visualizer import CameraVisualizer
from src.loader import load_quick, load_nerf, load_colmap
from src.utils import load_image, rescale_cameras, recenter_cameras
parser = argparse.ArgumentParser()
parser.add_argument('--root', type=str)
parser.add_argument('--format', default='quick', choices=['quick', 'nerf', 'colmap'])
parser.add_argument('--type', default=None, choices=[None, 'sph', 'xyz', 'elu', 'c2w', 'w2c'])
parser.add_argument('--no_images', action='store_true')
parser.add_argument('--mesh_path', type=str, default=None)
parser.add_argument('--image_size', type=int, default=256)
parser.add_argument('--scene_size', type=int, default=5)
parser.add_argument('--y_up', action='store_true')
parser.add_argument('--recenter', action='store_true')
parser.add_argument('--rescale', type=float, default=None)
args = parser.parse_args()
root_path = args.root
poses = []
legends = []
colors = []
images = None
if args.format == 'quick':
poses, legends, colors, image_paths = load_quick(root_path, args.type)
elif args.format == 'nerf':
poses, legends, colors, image_paths = load_nerf(root_path)
elif args.format == 'colmap':
poses, legends, colors, image_paths = load_colmap(root_path)
if args.recenter:
poses = recenter_cameras(poses)
if args.rescale is not None:
poses = rescale_cameras(poses, args.rescale)
if args.y_up:
for i in range(0, len(poses)):
poses[i] = poses[i][[0, 2, 1, 3]]
poses[i][1, :] *= -1
if not args.no_images:
images = []
for fpath in image_paths:
if fpath is None:
images.append(None)
continue
if not os.path.exists(fpath):
images.append(None)
print(f'Image not found at {fpath}')
continue
images.append(load_image(fpath, sz=args.image_size))
viz = CameraVisualizer(poses, legends, colors, images=images)
fig = viz.update_figure(args.scene_size, base_radius=1, zoom_scale=1, show_grid=True, show_ticklabels=True, show_background=True, y_up=args.y_up)
fig.show()