Skip to content

Commit

Permalink
Merge pull request #1449 from rgov/rzg/c2n-outpath
Browse files Browse the repository at this point in the history
colmap2nerf: Error on bad output path
  • Loading branch information
Tom94 authored Sep 19, 2023
2 parents b99cb33 + 6e44715 commit e838d02
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion scripts/colmap2nerf.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def parse_args():
parser.add_argument("--aabb_scale", default=32, choices=["1", "2", "4", "8", "16", "32", "64", "128"], help="Large scene scale factor. 1=scene fits in unit cube; power of 2 up to 128")
parser.add_argument("--skip_early", default=0, help="Skip this many images from the start.")
parser.add_argument("--keep_colmap_coords", action="store_true", help="Keep transforms.json in COLMAP's original frame of reference (this will avoid reorienting and repositioning the scene for preview and rendering).")
parser.add_argument("--out", default="transforms.json", help="Output path.")
parser.add_argument("--out", default="transforms.json", help="Output JSON file path.")
parser.add_argument("--vocab_path", default="", help="Vocabulary tree path.")
parser.add_argument("--overwrite", action="store_true", help="Do not ask for confirmation for overwriting existing images and COLMAP data.")
parser.add_argument("--mask_categories", nargs="*", type=str, default=[], help="Object categories that should be masked out from the training images. See `scripts/category2id.json` for supported categories.")
Expand Down Expand Up @@ -201,6 +201,14 @@ def closest_point_2_lines(oa, da, ob, db): # returns point closest to both rays
IMAGE_FOLDER = args.images
TEXT_FOLDER = args.text
OUT_PATH = args.out

# Check that we can save the output before we do a lot of work
try:
open(OUT_PATH, "a").close()
except Exception as e:
print(f"Could not save transforms JSON to {OUT_PATH}: {e}")
sys.exit(1)

print(f"outputting to {OUT_PATH}...")
cameras = {}
with open(os.path.join(TEXT_FOLDER,"cameras.txt"), "r") as f:
Expand Down

0 comments on commit e838d02

Please sign in to comment.