cvg / pixel-perfect-sfm

Pixel-Perfect Structure-from-Motion with Featuremetric Refinement (ICCV 2021, Best Student Paper Award)
Apache License 2.0
1.29k stars 132 forks source link

How to avoid resulting in multiple models? #125

Open linhanwang opened 8 months ago

linhanwang commented 8 months ago

I'm using pixsfm on a large dataset with 1900 images. I have a coarse images poses so I use pairs_from_poses. I tried pixsfm but got multiple small models. Do you have any tips to get a whole model? Maybe I use larger num_matches?

This is my code. It's from https://github.com/cvg/pixel-perfect-sfm/issues/23.

feature_conf = extract_features.confs['superpoint_max']
    matcher_conf = match_features.confs['superglue']

    images_path = Path(hparams.images_path)
    model_path = Path(hparams.model_path)

    images = sorted(images_path.iterdir())
    references = [str(images[i].relative_to(images_path)) for i in range(0, len(images), hparams.use_every)]
    print(len(references), 'mapping images')

    features_path = output_path / 'features.h5'
    sfm_pairs_path = output_path / 'pairs-sfm.txt'
    matches_path = output_path / 'matches.h5'

    extract_features.main(feature_conf, images_path, image_list=references, feature_path=features_path)
    # pairs_from_gps.main(sfm_pairs_path, images_path, references, 100, 4)
    pairs_from_poses.main(model_path, sfm_pairs_path, 100)
    print('Begin matching featues')
    sfm = PixSfM(conf={"dense_features": {"use_cache": True},
                       'KA': {'dense_features': {'use_cache': True}, 'max_kps_per_problem': 1000, "strategy": "topological_reference"},
                       'BA': {'strategy': 'costmaps'}})
    match_features.main(matcher_conf, sfm_pairs_path, features=features_path, matches=matches_path)

    print('Begin sfm')

    ref_dir = output_path / 'ref'
    refined, sfm_outputs = sfm.reconstruction(ref_dir, images_path, sfm_pairs_path, features_path, matches_path,
                                              image_list=references, verbose=True)