Skip to content

Commit

Permalink
add matching mode flag in imgs2poses
Browse files Browse the repository at this point in the history
this feature fixes a bug where linear videa images cause pose saving to fail.  now that different feature matching techniques can be specified, we can pass 'sequential_matcher' which results in success.  future work should accomodate other feature matching techniques
  • Loading branch information
blm81 committed Dec 7, 2019
1 parent 1c9f7a5 commit 1d46daa
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 6 deletions.
9 changes: 8 additions & 1 deletion imgs2poses.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,16 @@

import argparse
parser = argparse.ArgumentParser()
parser.add_argument('--match_type', type=str,
default='exhaustive_matcher', help='type of matcher used. Valid options: \
exhaustive_matcher sequential_matcher. Other matchers not supported at this time')
parser.add_argument('scenedir', type=str,
help='input scene directory')
args = parser.parse_args()

if args.match_type != 'exhaustive_matcher' and args.match_type != 'sequential_matcher':
print('ERROR: matcher type ' + args.match_type + ' is not valid. Aborting')
sys.exit()

if __name__=='__main__':
gen_poses(args.scenedir)
gen_poses(args.scenedir, args.match_type)
7 changes: 4 additions & 3 deletions llff/poses/colmap_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
# --output_path $DATASET_PATH/sparse

# $ mkdir $DATASET_PATH/dense
def run_colmap(basedir):
def run_colmap(basedir, match_type):

logfile_name = os.path.join(basedir, 'colmap_output.txt')
logfile = open(logfile_name, 'w')
Expand All @@ -35,11 +35,12 @@ def run_colmap(basedir):
feat_output = ( subprocess.check_output(feature_extractor_args, universal_newlines=True) )
logfile.write(feat_output)
print('Features extracted')

exhaustive_matcher_args = [
'colmap', 'exhaustive_matcher',
'colmap', match_type,
'--database_path', os.path.join(basedir, 'database.db'),
]

match_output = ( subprocess.check_output(exhaustive_matcher_args, universal_newlines=True) )
logfile.write(match_output)
print('Features matched')
Expand Down
7 changes: 5 additions & 2 deletions llff/poses/pose_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ def save_poses(basedir, poses, pts3d, perm):
pts_arr.append(pts3d[k].xyz)
cams = [0] * poses.shape[-1]
for ind in pts3d[k].image_ids:
if len(cams) < ind - 1:
print('ERROR: the correct camera poses for current points cannot be accessed')
return
cams[ind-1] = 1
vis_arr.append(cams)

Expand Down Expand Up @@ -253,7 +256,7 @@ def imread(f):



def gen_poses(basedir, factors=None):
def gen_poses(basedir, match_type, factors=None):

files_needed = ['{}.bin'.format(f) for f in ['cameras', 'images', 'points3D']]
if os.path.exists(os.path.join(basedir, 'sparse/0')):
Expand All @@ -262,7 +265,7 @@ def gen_poses(basedir, factors=None):
files_had = []
if not all([f in files_had for f in files_needed]):
print( 'Need to run COLMAP' )
run_colmap(basedir)
run_colmap(basedir, match_type)
else:
print('Don\'t need to run COLMAP')

Expand Down

0 comments on commit 1d46daa

Please sign in to comment.