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

Function run_perspective

python/examples/panorama_sfm.py:514–604  ·  view source on GitHub ↗

Render the panoramas into a rig of perspective virtual cameras and reconstruct from those.

(
    args: argparse.Namespace, database_path: Path, rec_path: Path
)

Source from the content-addressed store, hash-verified

512
513
514def run_perspective(
515 args: argparse.Namespace, database_path: Path, rec_path: Path
516) -> None:
517 """Render the panoramas into a rig of perspective virtual cameras and
518 reconstruct from those."""
519
520 logging.info("Reconstructing with rig of perspective virtual cameras")
521
522 image_dir = args.output_path / "images"
523 mask_dir = args.output_path / "masks"
524 image_dir.mkdir(exist_ok=True, parents=True)
525 mask_dir.mkdir(exist_ok=True, parents=True)
526
527 # Search for input images.
528 pano_image_dir = args.input_image_path
529 pano_image_names = sorted(
530 p.relative_to(pano_image_dir).as_posix()
531 for p in pano_image_dir.rglob("*")
532 if not p.is_dir()
533 )
534 logging.info(f"Found {len(pano_image_names)} images in {pano_image_dir}.")
535
536 processor = render_perspective_images(
537 pano_image_names,
538 pano_image_dir,
539 image_dir,
540 mask_dir,
541 PANO_RENDER_OPTIONS[args.pano_render_type],
542 )
543 rig_config = processor.rig_config
544
545 rendered_camera = rig_config.cameras[0].camera
546 assert rendered_camera is not None # Make mypy happy.
547 pycolmap.extract_features(
548 database_path,
549 image_dir,
550 reader_options=pycolmap.ImageReaderOptions(
551 mask_path=mask_dir,
552 camera_model=rendered_camera.model_name,
553 camera_params=rendered_camera.params_to_string(),
554 ),
555 camera_mode=pycolmap.CameraMode.PER_FOLDER,
556 )
557
558 with pycolmap.Database.open(database_path) as db:
559 pycolmap.apply_rig_config([rig_config], db)
560
561 matching_options = pycolmap.FeatureMatchingOptions()
562 # We have perfect sensor_from_rig poses (except for potential stitching
563 # artifacts by the spherical image provider), so we can perform geometric
564 # verification using rig constraints.
565 matching_options.rig_verification = True
566 # The images within a frame do not have overlap due to the provided masks.
567 matching_options.skip_image_pairs_in_same_frame = True
568 run_matcher(args, database_path, matching_options)
569
570 if args.mapper == Mapper.INCREMENTAL:
571 opts = pycolmap.IncrementalPipelineOptions(

Callers 1

runFunction · 0.85

Calls 4

run_matcherFunction · 0.85

Tested by

no test coverage detected