|
51 | 51 | except ImportError: |
52 | 52 | logger.error("pyvis is not available. Unable to visualize view graph.") |
53 | 53 |
|
54 | | -# If --skip_reconstruction is not specified, run reconstruction |
| 54 | +# If --skip_reconstruction is not specified, run reconstruction with pycolmap |
| 55 | +if not config.general["skip_reconstruction"]: |
| 56 | + from deep_image_matching.reconstruction import pycolmap_reconstruction |
| 57 | + |
| 58 | + # Optional - You can specify some reconstruction configuration |
| 59 | + # reconst_opts = ( |
| 60 | + # { |
| 61 | + # "ba_refine_focal_length": True, |
| 62 | + # "ba_refine_principal_point": False, |
| 63 | + # "ba_refine_extra_params": False, |
| 64 | + # }, |
| 65 | + # ) |
| 66 | + reconst_opts = {} |
| 67 | + refine_intrinsics = config.general.get("refine_intrinsics", True) |
| 68 | + |
| 69 | + # Run reconstruction |
| 70 | + model = pycolmap_reconstruction( |
| 71 | + database_path=output_dir / "database.db", |
| 72 | + sfm_dir=output_dir, |
| 73 | + image_dir=imgs_dir, |
| 74 | + options=reconst_opts, |
| 75 | + verbose=config.general["verbose"], |
| 76 | + refine_intrinsics=refine_intrinsics, |
| 77 | + ) |
| 78 | + |
55 | 79 | # Export in openMVG format |
56 | 80 | if config.general["openmvg_conf"]: |
57 | 81 | with open(config.general["openmvg_conf"]) as file: |
58 | 82 | openmvgcfg = yaml.safe_load(file) |
59 | 83 | openmvg_sfm_bin = openmvgcfg["general"]["path_to_binaries"] |
60 | 84 | openmvg_database = openmvgcfg["general"]["openmvg_database"] |
61 | 85 | openmvg_out_path = output_dir / "openmvg" |
62 | | - |
63 | 86 | dim.io.export_to_openmvg( |
64 | 87 | img_dir=imgs_dir, |
65 | 88 | feature_path=feature_path, |
|
70 | 93 | camera_config_path=config.general["camera_options"], |
71 | 94 | ) |
72 | 95 |
|
73 | | - # Reconstruction with OpenMVG |
74 | | - reconstruction = import_module("deep_image_matching.openmvg_reconstruction") |
75 | | - reconstruction.main( |
76 | | - openmvg_out_path=openmvg_out_path, |
77 | | - skip_reconstruction=config.general["skip_reconstruction"], |
78 | | - openmvg_sfm_bin=openmvg_sfm_bin, |
79 | | - ) |
| 96 | + # If skip_reconstruction is not specified, run OpenMVG reconstruction |
| 97 | + if not config.general["skip_reconstruction"]: |
| 98 | + from deep_image_matching.openmvg import openmvg_reconstruction |
80 | 99 |
|
81 | | -# Reconstruction with pycolmap |
82 | | -if not config.general["skip_reconstruction"]: |
83 | | - use_pycolmap = True |
84 | | - try: |
85 | | - # To be sure, check if pycolmap is available, otherwise skip reconstruction |
86 | | - pycolmap = import_module("pycolmap") |
87 | | - logger.info(f"Using pycolmap version {pycolmap.__version__}") |
88 | | - except ImportError: |
89 | | - logger.error("Pycomlap is not available.") |
90 | | - use_pycolmap = False |
91 | | - |
92 | | - if use_pycolmap: |
93 | | - # import reconstruction module |
94 | | - reconstruction = import_module("deep_image_matching.reconstruction") |
95 | | - |
96 | | - # Optional - You can specify some reconstruction configuration |
97 | | - # reconst_opts = ( |
98 | | - # { |
99 | | - # "ba_refine_focal_length": True, |
100 | | - # "ba_refine_principal_point": False, |
101 | | - # "ba_refine_extra_params": False, |
102 | | - # }, |
103 | | - # ) |
104 | | - reconst_opts = {} |
105 | | - refine_intrinsics = config.general.get("refine_intrinsics", True) |
106 | | - |
107 | | - # Run reconstruction |
108 | | - model = reconstruction.pycolmap_reconstruction( |
109 | | - database_path=output_dir / "database.db", |
110 | | - sfm_dir=output_dir, |
111 | | - image_dir=imgs_dir, |
112 | | - options=reconst_opts, |
113 | | - verbose=config.general["verbose"], |
114 | | - refine_intrinsics=refine_intrinsics, |
| 100 | + openmvg_reconstruction( |
| 101 | + openmvg_out_path=openmvg_out_path, |
| 102 | + skip_reconstruction=config.general["skip_reconstruction"], |
| 103 | + openmvg_sfm_bin=openmvg_sfm_bin, |
115 | 104 | ) |
0 commit comments