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

Function reconstruct

python/examples/custom_incremental_pipeline.py:294–378  ·  view source on GitHub ↗

Equivalent to IncrementalPipeline.reconstruct(...)

(
    controller: IncrementalPipeline,
    mapper: IncrementalMapper,
    mapper_options: IncrementalMapperOptions,
    continue_reconstruction: bool,
)

Source from the content-addressed store, hash-verified

292
293
294def reconstruct(
295 controller: IncrementalPipeline,
296 mapper: IncrementalMapper,
297 mapper_options: IncrementalMapperOptions,
298 continue_reconstruction: bool,
299) -> IncrementalPipelineStatus:
300 """Equivalent to IncrementalPipeline.reconstruct(...)"""
301 options = controller.options
302
303 database_cache = controller.database_cache
304 reconstruction_manager = controller.reconstruction_manager
305
306 for num_trials in range(options.init_num_trials):
307 if controller.check_reached_max_runtime():
308 break
309 if not continue_reconstruction or num_trials > 0:
310 reconstruction_idx = reconstruction_manager.add()
311 else:
312 reconstruction_idx = 0
313
314 reconstruction = reconstruction_manager.get(reconstruction_idx)
315 status = reconstruct_sub_model(
316 controller, mapper, mapper_options, reconstruction
317 )
318 if status == IncrementalPipelineStatus.INTERRUPTED:
319 reconstruction.update_point_3d_errors()
320 logging.info("Keeping reconstruction due to interrupt")
321 mapper.end_reconstruction(False)
322 pycolmap.align_reconstruction_to_orig_rig_scales(
323 database_cache.rigs, reconstruction
324 )
325 elif status == IncrementalPipelineStatus.UNKNOWN_SENSOR_FROM_RIG:
326 logging.error(
327 "Discarding reconstruction due to unknown sensor_from_rig "
328 "poses. Either explicitly define the poses by configuring the "
329 "rigs or first run reconstruction without configured rigs and "
330 "then derive the poses from the initial reconstruction for a "
331 "subsequent reconstruction with rig constraints. See "
332 "documentation for detailed instructions."
333 )
334 mapper.end_reconstruction(True)
335 reconstruction_manager.delete(reconstruction_idx)
336 return IncrementalPipelineStatus.STOP
337 elif status == IncrementalPipelineStatus.BAD_INITIAL_PAIR:
338 logging.info("Disacarding reconstruction due to bad initial pair")
339 mapper.end_reconstruction(True)
340 reconstruction_manager.delete(reconstruction_idx)
341 elif status == IncrementalPipelineStatus.NO_INITIAL_PAIR:
342 logging.info("Disacarding reconstruction due to no initial pair")
343 mapper.end_reconstruction(True)
344 reconstruction_manager.delete(reconstruction_idx)
345 return IncrementalPipelineStatus.CONTINUE
346 elif status == IncrementalPipelineStatus.SUCCESS:
347 num_reg_images = reconstruction.num_reg_images()
348 total_num_reg_images = mapper.num_total_reg_images()
349 if (
350 options.multiple_models
351 and reconstruction_manager.size() > 1

Callers 1

main_incremental_mapperFunction · 0.85

Calls 2

reconstruct_sub_modelFunction · 0.85
sizeMethod · 0.80

Tested by

no test coverage detected