Equivalent to IncrementalPipeline.reconstruct_sub_model(...)
(
controller: IncrementalPipeline,
mapper: IncrementalMapper,
mapper_options: IncrementalMapperOptions,
reconstruction: Reconstruction,
)
| 132 | |
| 133 | |
| 134 | def reconstruct_sub_model( |
| 135 | controller: IncrementalPipeline, |
| 136 | mapper: IncrementalMapper, |
| 137 | mapper_options: IncrementalMapperOptions, |
| 138 | reconstruction: Reconstruction, |
| 139 | ) -> IncrementalPipelineStatus: |
| 140 | """Equivalent to IncrementalPipeline.reconstruct_sub_model(...)""" |
| 141 | mapper.begin_reconstruction(reconstruction) |
| 142 | |
| 143 | if has_unknown_sensor_from_rig(reconstruction): |
| 144 | return IncrementalPipelineStatus.UNKNOWN_SENSOR_FROM_RIG |
| 145 | |
| 146 | if reconstruction.num_reg_frames() == 0: |
| 147 | init_status = initialize_reconstruction( |
| 148 | controller, mapper, mapper_options, reconstruction |
| 149 | ) |
| 150 | if init_status != IncrementalPipelineStatus.SUCCESS: |
| 151 | return init_status |
| 152 | controller.callback( |
| 153 | IncrementalPipelineCallback.INITIAL_IMAGE_PAIR_REG_CALLBACK |
| 154 | ) |
| 155 | |
| 156 | options = controller.options |
| 157 | |
| 158 | structure_less_flags = [] |
| 159 | if options.structure_less_registration_only: |
| 160 | structure_less_flags = [True] |
| 161 | else: |
| 162 | if options.structure_less_registration_fallback: |
| 163 | structure_less_flags = [False, True] |
| 164 | else: |
| 165 | structure_less_flags = [False] |
| 166 | |
| 167 | snapshot_prev_num_reg_frames = reconstruction.num_reg_frames() |
| 168 | ba_prev_num_reg_frames = reconstruction.num_reg_frames() |
| 169 | ba_prev_num_points = reconstruction.num_points3D() |
| 170 | reg_next_success, prev_reg_next_success = True, True |
| 171 | while True: |
| 172 | if not (reg_next_success or prev_reg_next_success): |
| 173 | break |
| 174 | if controller.check_reached_max_runtime(): |
| 175 | break |
| 176 | prev_reg_next_success = reg_next_success |
| 177 | reg_next_success = False |
| 178 | next_image_id = None |
| 179 | for structure_less in structure_less_flags: |
| 180 | next_images = mapper.find_next_images( |
| 181 | mapper_options, structure_less=structure_less |
| 182 | ) |
| 183 | for reg_trial, next_image_id in enumerate(next_images): |
| 184 | logging.info( |
| 185 | f"Registering image #{next_image_id} " |
| 186 | f"(num_reg_frames={reconstruction.num_reg_frames()})" |
| 187 | ) |
| 188 | if structure_less: |
| 189 | logging.info( |
| 190 | "Registering image with structure-less fallback" |
| 191 | ) |
no test coverage detected