Skip to content

Commit

Permalink
Minor fixes in scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonios Matakos committed Sep 15, 2021
1 parent 01461a1 commit cc72127
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
10 changes: 8 additions & 2 deletions colmap_input.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def read_images_binary(path: str) -> List[Image]:
qvec = binary_image_properties[1:5]
tvec = binary_image_properties[5:8]
cam_id = binary_image_properties[8]
image_name = ''
image_name = ""
current_char = read_next_bytes(fid, 1, "c")[0]
while current_char != b"\x00": # look for the ASCII 0 entry
image_name += current_char.decode("utf-8")
Expand Down Expand Up @@ -249,7 +249,7 @@ def quaternion_to_rotation_matrix(qvec: List[float]) -> np.ndarray:
parser = argparse.ArgumentParser(description="Convert colmap results into input for PatchmatchNet")

parser.add_argument("--input_folder", type=str, help="Project input dir.")
parser.add_argument("--output_folder", type=str, default='', help="Project output dir.")
parser.add_argument("--output_folder", type=str, default="", help="Project output dir.")
parser.add_argument("--num_src_images", type=int, default=-1, help="Related images")
parser.add_argument("--theta0", type=float, default=5)
parser.add_argument("--sigma1", type=float, default=1)
Expand All @@ -262,6 +262,12 @@ def quaternion_to_rotation_matrix(qvec: List[float]) -> np.ndarray:
if not args.output_folder:
args.output_folder = args.input_folder

if args.input_folder is None or not os.path.isdir(args.input_folder):
raise Exception("Invalid input folder")

if args.output_folder is None or not os.path.isdir(args.output_folder):
raise Exception("Invalid output folder")

image_dir = os.path.join(args.input_folder, "images")
model_dir = os.path.join(args.input_folder, "sparse")
cam_dir = os.path.join(args.output_folder, "cams")
Expand Down
13 changes: 11 additions & 2 deletions colmap_output.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ def write_points_3d(path: str):
parser = argparse.ArgumentParser(description="Convert colmap results into input for PatchMatchNet")

parser.add_argument("--input_folder", type=str, help="Input PatchMatchNet reconstruction dir")
parser.add_argument("--results_folder", type=str, help="Input PatchMatchNet results dir")
parser.add_argument("--output_folder", type=str, default='', help="Output ColMap MVS workspace")
parser.add_argument("--results_folder", type=str, default="", help="Input PatchMatchNet results dir")
parser.add_argument("--output_folder", type=str, default="", help="Output ColMap MVS workspace")

args = parser.parse_args()

Expand All @@ -136,6 +136,15 @@ def write_points_3d(path: str):
if not args.output_folder:
args.output_folder = args.input_folder

if args.input_folder is None or not os.path.isdir(args.input_folder):
raise Exception("Invalid input folder")

if args.results_folder is None or not os.path.isdir(args.results_folder):
raise Exception("Invalid results folder")

if args.output_folder is None or not os.path.isdir(args.output_folder):
raise Exception("Invalid output folder")

create_output_dirs(args.output_folder)
copy_maps(args.input_folder, args.results_folder, args.output_folder)
cams, ims, im_pairs = read_reconstruction(args.input_folder)
Expand Down
3 changes: 1 addition & 2 deletions convert_eth3d_dataset.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import argparse
import numpy as np
import os
import shutil
from datasets.data_io import read_image_dictionary
Expand Down Expand Up @@ -61,7 +60,7 @@

# Copy GT depth map
depth_gt_filename = os.path.join(args.input_folder, scan, "depths", image_index[view_id])
depth_gt_filename = os.path.splitext(depth_gt_filename.replace('_undistorted', ''))[0] + '.pfm'
depth_gt_filename = os.path.splitext(depth_gt_filename.replace("_undistorted", ""))[0] + ".pfm"
shutil.copy(depth_gt_filename, os.path.join(depth_path, "{:0>8}.pfm".format(view_id)))

# Create mask from GT depth map and save in output
Expand Down

0 comments on commit cc72127

Please sign in to comment.