-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcolmap_basenames.py
56 lines (42 loc) · 1.18 KB
/
colmap_basenames.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
#!/usr/bin/env python3
"""
Rename images in the COLMAP model to contain only basenames (without directories)
"""
import os
import argparse
import pycolmap
parser = argparse.ArgumentParser(
description="Rename images in the COLMAP model to contain only basenames"
)
parser.add_argument(
"--input_colmap",
type=str,
help="Input COLMAP model directory"
)
parser.add_argument(
"--output_colmap",
type=str,
help="Output COLMAP model directory"
)
parser.add_argument(
"--output_mode",
type=str,
choices=["TXT", "BIN"],
default="TXT",
help="Output COLMAP model format - TXT / BIN",
)
def main(args):
assert os.path.isdir(args.input_colmap)
assert os.path.isdir(args.output_colmap)
model = pycolmap.Reconstruction(args.input_colmap)
for image_id in model.images.keys():
image = model.images[image_id]
image.name = os.path.basename(image.name)
model.images[image_id] = image
if args.output_mode == "TXT":
model.write_text(args.output_colmap)
elif args.output_mode == "BIN":
model.write_binary(args.output_colmap)
if __name__ == "__main__":
args = parser.parse_args()
main(args)