@@ -41,15 +41,19 @@ def get_image_ids(database_path):
41
41
return images
42
42
43
43
44
- def run_reconstruction (sfm_dir , database_path , image_dir , verbose = False ):
44
+ def run_reconstruction (sfm_dir , database_path , image_dir , use_pba = False , verbose = False ):
45
45
models_path = sfm_dir / 'models'
46
46
models_path .mkdir (exist_ok = True , parents = True )
47
47
logger .info ('Running 3D reconstruction...' )
48
48
with OutputCapture (verbose ):
49
49
with pycolmap .ostream ():
50
+ opt = pycolmap .IncrementalMapperOptions ()
51
+ opt .num_threads = min (multiprocessing .cpu_count (), 16 )
52
+ if use_pba :
53
+ opt .ba_global_use_pba = True
50
54
reconstructions = pycolmap .incremental_mapping (
51
55
database_path , image_dir , models_path ,
52
- num_threads = min ( multiprocessing . cpu_count (), 16 ) )
56
+ opt )
53
57
54
58
if len (reconstructions ) == 0 :
55
59
logger .error ('Could not reconstruct any model!' )
@@ -76,7 +80,7 @@ def run_reconstruction(sfm_dir, database_path, image_dir, verbose=False):
76
80
77
81
78
82
def main (sfm_dir , image_dir , pairs , features , matches ,
79
- camera_mode = pycolmap .CameraMode .AUTO , verbose = False ,
83
+ camera_mode = pycolmap .CameraMode .AUTO , verbose = False , use_pba = False ,
80
84
skip_geometric_verification = False , min_match_score = None ,
81
85
image_list : Optional [List [str ]] = None ):
82
86
@@ -95,7 +99,7 @@ def main(sfm_dir, image_dir, pairs, features, matches,
95
99
min_match_score , skip_geometric_verification )
96
100
if not skip_geometric_verification :
97
101
geometric_verification (database , pairs , verbose )
98
- reconstruction = run_reconstruction (sfm_dir , database , image_dir , verbose )
102
+ reconstruction = run_reconstruction (sfm_dir , database , image_dir , use_pba , verbose )
99
103
if reconstruction is not None :
100
104
logger .info (f'Reconstruction statistics:\n { reconstruction .summary ()} '
101
105
+ f'\n \t num_input_images = { len (image_ids )} ' )
@@ -116,6 +120,7 @@ def main(sfm_dir, image_dir, pairs, features, matches,
116
120
parser .add_argument ('--skip_geometric_verification' , action = 'store_true' )
117
121
parser .add_argument ('--min_match_score' , type = float )
118
122
parser .add_argument ('--verbose' , action = 'store_true' )
123
+ parser .add_argument ('--use_pba' , action = 'store_true' )
119
124
args = parser .parse_args ()
120
125
121
126
main (** args .__dict__ )
0 commit comments