MCPcopy Create free account
hub / github.com/colmap/colmap / iterative_global_refinement

Function iterative_global_refinement

python/examples/custom_bundle_adjustment.py:98–131  ·  view source on GitHub ↗

Equivalent to mapper.iterative_global_refinement(...)

(
    mapper: pycolmap.IncrementalMapper,
    max_num_refinements: int,
    max_refinement_change: float,
    mapper_options: pycolmap.IncrementalMapperOptions,
    ba_options: pycolmap.BundleAdjustmentOptions,
    tri_options: pycolmap.IncrementalTriangulatorOptions,
    normalize_reconstruction: bool = True,
)

Source from the content-addressed store, hash-verified

96
97
98def iterative_global_refinement(
99 mapper: pycolmap.IncrementalMapper,
100 max_num_refinements: int,
101 max_refinement_change: float,
102 mapper_options: pycolmap.IncrementalMapperOptions,
103 ba_options: pycolmap.BundleAdjustmentOptions,
104 tri_options: pycolmap.IncrementalTriangulatorOptions,
105 normalize_reconstruction: bool = True,
106) -> bool:
107 """Equivalent to mapper.iterative_global_refinement(...)"""
108 reconstruction = mapper.reconstruction
109 mapper.complete_and_merge_tracks(tri_options)
110 num_retriangulated_observations = mapper.retriangulate(tri_options)
111 logging.verbose(
112 1, f"=> Retriangulated observations: {num_retriangulated_observations}"
113 )
114 for _ in range(max_num_refinements):
115 num_observations = reconstruction.compute_num_observations()
116 # mapper.adjust_global_bundle(mapper_options, ba_options)
117 if not adjust_global_bundle(mapper, mapper_options, ba_options):
118 return False
119 if normalize_reconstruction:
120 reconstruction.normalize()
121 num_changed_observations = mapper.complete_and_merge_tracks(tri_options)
122 num_changed_observations += mapper.filter_points(mapper_options)
123 changed = (
124 num_changed_observations / num_observations
125 if num_observations > 0
126 else 0
127 )
128 logging.verbose(1, f"=> Changed observations: {changed:.6f}")
129 if changed < max_refinement_change:
130 break
131 return True
132
133
134def adjust_local_bundle(

Callers

nothing calls this directly

Calls 1

adjust_global_bundleFunction · 0.85

Tested by

no test coverage detected