Commit 4368bfa3 authored by Clément Pinard's avatar Clément Pinard
Browse files

handle indoor case

* To do : use flight data to deduce model scale
parent 181d8fe7
......@@ -54,6 +54,7 @@ def set_argparser():
exec_parser.add_argument("--pcl_util", default="pcl_util/build", type=Path)
pm_parser = parser.add_argument_group("Photogrammetry")
pm_parser.add_argument('--max_num_matches', default=32768, type=int, help="max number of matches, lower it if you get GPU memory error")
pm_parser.add_argument('--vocab_tree', type=Path, default="vocab_tree_flickr100K_words256K.bin")
pm_parser.add_argument('--triangulate', action="store_true")
pm_parser.add_argument('--multiple_models', action='store_true', help='If selected, will let colmap mapper do multiple models.'
......
......@@ -73,6 +73,8 @@ def main():
no_gt_folder = args.input_folder/"Videos"/"no_groundtruth"
if no_gt_folder.isdir():
env["videos_to_localize"] = [v for v in env["videos_list"] if not str(v).startswith(no_gt_folder)]
else:
env["videos_to_localize"] = env["videos_list"]
i = 1
if i not in args.skip_step:
......@@ -114,7 +116,7 @@ def main():
env["thorough_recon"].makedirs_p()
colmap.extract_features(image_list=env["video_frame_list_thorough"], more=args.more_sift_features)
colmap.index_images(vocab_tree_output=env["indexed_vocab_tree"], vocab_tree_input=args.vocab_tree)
colmap.match(method="vocab_tree", vocab_tree=env["indexed_vocab_tree"])
colmap.match(method="vocab_tree", vocab_tree=env["indexed_vocab_tree"], max_num_matches=env["max_num_matches"])
colmap.map(output=env["thorough_recon"], multiple_models=env["multiple_models"])
thorough_model = pi.choose_biggest_model(env["thorough_recon"])
colmap.adjust_bundle(thorough_model, thorough_model,
......@@ -132,7 +134,7 @@ def main():
if not (env["georef_frames_list"]/"images.bin").isfile():
# GPS alignment failed, possibly because not enough GPS referenced images
# Copy the original model without alignment
(env["thorough_recon"] / "0").merge_tree(env["georef_full_recon"])
(env["thorough_recon"] / "0").merge_tree(env["georef_recon"])
env["georef_recon"].merge_tree(env["georef_full_recon"])
if args.inspect_dataset:
colmap.export_model(output=env["georef_recon"] / "georef_sparse.ply",
......
......@@ -72,7 +72,7 @@ def main():
env["thorough_recon"].makedirs_p()
colmap.extract_features(image_list=env["video_frame_list_thorough"], more=args.more_sift_features)
colmap.index_images(vocab_tree_output=env["indexed_vocab_tree"], vocab_tree_input=args.vocab_tree)
colmap.match(method="vocab_tree", vocab_tree=env["indexed_vocab_tree"])
colmap.match(method="vocab_tree", vocab_tree=env["indexed_vocab_tree"], max_num_matches=env["max_num_matches"])
colmap.map(output=env["thorough_recon"], multiple_models=env["multiple_models"])
thorough_model = pi.choose_biggest_model(env["thorough_recon"])
colmap.adjust_bundle(thorough_model, thorough_model,
......@@ -90,7 +90,7 @@ def main():
if not (env["georef_frames_list"]/"images.bin").isfile():
# GPS alignment failed, possibly because not enough GPS referenced images
# Copy the original model without alignment
(env["thorough_recon"] / "0").merge_tree(env["georef_full_recon"])
(env["thorough_recon"] / "0").merge_tree(env["georef_recon"])
env["georef_recon"].merge_tree(env["georef_full_recon"])
if args.inspect_dataset:
colmap.export_model(output=env["georef_recon"] / "georef_sparse.ply",
......
......@@ -19,12 +19,12 @@ def is_video_in_model(video_name, colmap_model, metadata):
return sum(video_image_ids.isin(mapped_images_ids)) > 0
def sift_and_match(colmap, more_sift_features, indexed_vocab_tree, image_list, **env):
def sift_and_match(colmap, more_sift_features, indexed_vocab_tree, image_list, max_num_matches, **env):
tries = 0
while tries < 10:
try:
colmap.extract_features(image_list=image_list, more=more_sift_features)
colmap.match(method="sequential", vocab_tree=indexed_vocab_tree)
colmap.match(method="sequential", vocab_tree=indexed_vocab_tree, max_num_matches=max_num_matches)
except Exception:
# If it failed, that's because sift gpu has failed.
print("Error With colmap, will retry")
......
......@@ -29,10 +29,11 @@ class Colmap(Wrapper):
pass
self.__call__(options)
def match(self, method="exhaustive", guided_matching=True, vocab_tree=None):
def match(self, method="exhaustive", guided_matching=True, vocab_tree=None, max_num_matches=32768):
options = ["{}_matcher".format(method),
"--database_path", self.db,
"--SiftMatching.guided_matching", "1" if guided_matching else "0"]
"--SiftMatching.guided_matching", "1" if guided_matching else "0",
"--SiftMatching.max_num_matches", str(max_num_matches)]
if method == "sequential":
assert vocab_tree is not None
options += ["--SequentialMatching.loop_detection", "1",
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment