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

Function main

python/examples/custom_incremental_pipeline.py:462–504  ·  view source on GitHub ↗
(
    database_path: Path,
    image_path: Path,
    output_path: Path,
    options: IncrementalPipelineOptions | None = None,
    input_path: Path | None = None,
)

Source from the content-addressed store, hash-verified

460
461
462def main(
463 database_path: Path,
464 image_path: Path,
465 output_path: Path,
466 options: IncrementalPipelineOptions | None = None,
467 input_path: Path | None = None,
468) -> dict[int, Reconstruction]:
469 if options is None:
470 options = IncrementalPipelineOptions()
471 options.image_path = image_path
472 if not database_path.exists():
473 logging.fatal(f"Database path does not exist: {database_path}")
474 if not image_path.exists():
475 logging.fatal(f"Image path does not exist: {image_path}")
476 output_path.mkdir(exist_ok=True, parents=True)
477 reconstruction_manager = ReconstructionManager()
478 if input_path:
479 reconstruction_manager.read(input_path)
480
481 with pycolmap.Database.open(database_path) as database:
482 mapper = IncrementalPipeline(options, database, reconstruction_manager)
483 num_images = database.num_images()
484 with enlighten.Manager() as manager:
485 with manager.counter(
486 total=num_images, desc="Images registered:"
487 ) as pbar:
488 pbar.update(0, force=True)
489 mapper.add_callback(
490 IncrementalPipelineCallback.INITIAL_IMAGE_PAIR_REG_CALLBACK,
491 lambda: pbar.update(2),
492 )
493 mapper.add_callback(
494 IncrementalPipelineCallback.NEXT_IMAGE_REG_CALLBACK,
495 lambda: pbar.update(1),
496 )
497 main_incremental_mapper(mapper)
498
499 # write and output
500 reconstruction_manager.write(output_path)
501 reconstructions = {}
502 for i in range(reconstruction_manager.size()):
503 reconstructions[i] = reconstruction_manager.get(i)
504 return reconstructions
505
506
507def parse_args() -> argparse.Namespace:

Callers 1

Calls 5

IncrementalPipelineClass · 0.85
main_incremental_mapperFunction · 0.85
sizeMethod · 0.80

Tested by

no test coverage detected