Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding Code to Tweak b/w cameras model(OPENCV, PINHOLE) & (single camera or multiple camera) #149

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 25 additions & 4 deletions pixsfm/refine_hloc.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,13 @@ def reconstruction(
reference_model_path=None, cache_path=cache_path,
feature_manager=feature_manager, **hloc_args)

def add_camera_args(parser):
parser.add_argument(
'--camera_model', type=str, default='OPENCV',
help='Camera model for the image reader options.')
parser.add_argument(
'--single_camera', action='store_true',
help='Enable single camera mode for reconstruction.')

def add_hloc_args(parser):
parser.add_argument(
Expand All @@ -170,14 +177,15 @@ def add_hloc_args(parser):
help='Output HDF5 file where the refine keypoints will be written.')
add_hloc_args(parser_ka)
add_common_args(parser_ka)

parser_rec = subparsers.add_parser(
'reconstructor', aliases=['rec', 'sfm'],
help='Full 3D reconstruction with keypoint and bundle adjustments.')
parser_rec.add_argument(
'--sfm_dir', type=Path, required=True, help='Output SfM model.')
add_hloc_args(parser_rec)
add_common_args(parser_rec)
add_camera_args(parser_rec)

parser_tri = subparsers.add_parser(
'triangulator', aliases=['tri'],
Expand All @@ -197,19 +205,32 @@ def add_hloc_args(parser):
if args.config is not None:
conf = OmegaConf.merge(OmegaConf.load(args.config), conf)
sfm = PixSfM(conf)

camera_model = args.camera_model if 'camera_model' in args else 'OPENCV'
image_options = pycolmap.ImageReaderOptions(camera_model=camera_model)

if args.command == 'keypoint_adjuster':
logger.info("Will perform keypoint adjustment.")
logger.info("Received arguments for 3D triangulation: %s", args)
sfm.refine_keypoints(
args.output_path, args.features_path, args.image_dir,
args.pairs_path, args.matches_path, cache_path=args.cache_path)
elif args.command == 'reconstructor':
logger.info("Will perform full 3D reconstruction.")
sfm.reconstruction(
args.sfm_dir, args.image_dir, args.pairs_path, args.features_path,
args.matches_path, cache_path=args.cache_path)
logger.info("Received arguments for 3D triangulation: %s", args)
if args.single_camera:
sfm.reconstruction(
args.sfm_dir, args.image_dir, args.pairs_path, args.features_path,
args.matches_path, cache_path=args.cache_path, camera_mode=pycolmap.CameraMode.SINGLE,
image_options=image_options)
else:
sfm.reconstruction(
args.sfm_dir, args.image_dir, args.pairs_path, args.features_path,
args.matches_path, cache_path=args.cache_path,
image_options=image_options)
elif args.command == 'triangulator':
logger.info("Will perform 3D triangulation.")
logger.info("Received arguments for 3D triangulation: %s", args)
sfm.triangulation(
args.sfm_dir, args.reference_sfm_model,
args.image_dir, args.pairs_path, args.features_path,
Expand Down