Skip to content
Snippets Groups Projects
Unverified Commit de507662 authored by Thomas Müller's avatar Thomas Müller Committed by GitHub
Browse files

Merge pull request #4 from mjc619/master

Getting colmap2nerf.py to work under Windows
parents f93a615d 85751f9c
No related branches found
No related tags found
No related merge requests found
......@@ -18,6 +18,7 @@ import sys
import math
import cv2
import os
import shutil
def parse_args():
parser = argparse.ArgumentParser(description="convert a text colmap export to nerf format transforms.json; optionally convert video to images, and optionally run colmap in the first place")
......@@ -52,7 +53,10 @@ def run_ffmpeg(args):
print(f"running ffmpeg with input video file={video}, output image folder={images}, fps={fps}.")
if (input(f"warning! folder '{images}' will be deleted/replaced. continue? (Y/n)").lower().strip()+"y")[:1] != "y":
sys.exit(1)
do_system(f"rm -rf {images}")
try:
shutil.rmtree(images)
except:
pass
do_system(f"mkdir {images}")
do_system(f"ffmpeg -i {video} -qscale:v 1 -qmin 1 -vf \"fps={fps}\" {images}/%04d.jpg")
......@@ -72,11 +76,17 @@ def run_colmap(args):
os.remove(db)
do_system(f"colmap feature_extractor --ImageReader.camera_model OPENCV --ImageReader.single_camera 1 --database_path {db} --image_path {images}")
do_system(f"colmap {args.colmap_matcher}_matcher --database_path {db}")
do_system(f"rm -rf {sparse}")
try:
shutil.rmtree(sparse)
except:
pass
do_system(f"mkdir {sparse}")
do_system(f"colmap mapper --database_path {db} --image_path {images} --output_path {sparse}")
do_system(f"colmap bundle_adjuster --input_path {sparse}/0 --output_path {sparse}/0 --BundleAdjustment.refine_principal_point 1")
do_system(f"rm -rf {text}")
try:
shutil.rmtree(text)
except:
pass
do_system(f"mkdir {text}")
do_system(f"colmap model_converter --input_path {sparse}/0 --output_path {text} --output_type TXT")
......@@ -215,7 +225,10 @@ if __name__ == "__main__":
continue
if i%2==1 :
elems=line.split(" ") # 1-4 is quat, 5-7 is trans, 9 is filename
name = str(PurePosixPath(Path(IMAGE_FOLDER, elems[9])))
#name = str(PurePosixPath(Path(IMAGE_FOLDER, elems[9])))
# why is this requireing a relitive path while using ^
image_rel = os.path.relpath(IMAGE_FOLDER)
name = str(f"./{image_rel}/{elems[9]}")
b=sharpness(name)
print(name, "sharpness=",b)
image_id = int(elems[0])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment