Equivalent to mapper.iterative_local_refinement(...)
(
mapper: pycolmap.IncrementalMapper,
max_num_refinements: int,
max_refinement_change: float,
mapper_options: pycolmap.IncrementalMapperOptions,
ba_options: pycolmap.BundleAdjustmentOptions,
tri_options: pycolmap.IncrementalTriangulatorOptions,
image_id: int,
)
| 255 | |
| 256 | |
| 257 | def iterative_local_refinement( |
| 258 | mapper: pycolmap.IncrementalMapper, |
| 259 | max_num_refinements: int, |
| 260 | max_refinement_change: float, |
| 261 | mapper_options: pycolmap.IncrementalMapperOptions, |
| 262 | ba_options: pycolmap.BundleAdjustmentOptions, |
| 263 | tri_options: pycolmap.IncrementalTriangulatorOptions, |
| 264 | image_id: int, |
| 265 | ) -> None: |
| 266 | """Equivalent to mapper.iterative_local_refinement(...)""" |
| 267 | custom_ba_options = copy.deepcopy(ba_options) |
| 268 | for _ in range(max_num_refinements): |
| 269 | # report = mapper.adjust_local_bundle( |
| 270 | # mapper_options, |
| 271 | # custom_ba_options, |
| 272 | # tri_options, |
| 273 | # image_id, |
| 274 | # mapper.get_modified_points3D(), |
| 275 | # ) |
| 276 | report = adjust_local_bundle( |
| 277 | mapper, |
| 278 | mapper_options, |
| 279 | custom_ba_options, |
| 280 | tri_options, |
| 281 | image_id, |
| 282 | mapper.get_modified_points3D(), |
| 283 | ) |
| 284 | logging.verbose( |
| 285 | 1, f"=> Merged observations: {report.num_merged_observations}" |
| 286 | ) |
| 287 | logging.verbose( |
| 288 | 1, f"=> Completed observations: {report.num_completed_observations}" |
| 289 | ) |
| 290 | logging.verbose( |
| 291 | 1, f"=> Filtered observations: {report.num_filtered_observations}" |
| 292 | ) |
| 293 | changed = 0.0 |
| 294 | if report.num_adjusted_observations > 0: |
| 295 | changed = ( |
| 296 | report.num_merged_observations |
| 297 | + report.num_completed_observations |
| 298 | + report.num_filtered_observations |
| 299 | ) / report.num_adjusted_observations |
| 300 | logging.verbose(1, f"=> Changed observations: {changed:.6f}") |
| 301 | if changed < max_refinement_change: |
| 302 | break |
| 303 | |
| 304 | # Only use robust cost function for first iteration |
| 305 | custom_ba_options.ceres.loss_function_type = ( |
| 306 | pycolmap.LossFunctionType.TRIVIAL |
| 307 | ) |
| 308 | mapper.clear_modified_points3D() |
nothing calls this directly
no test coverage detected