| 101 | } // namespace |
| 102 | |
| 103 | std::vector<image_t> IncrementalMapperImpl::FindFirstInitialImage( |
| 104 | const IncrementalMapper::Options& options, |
| 105 | const CorrespondenceGraph& correspondence_graph, |
| 106 | const Reconstruction& reconstruction, |
| 107 | const std::unordered_map<image_t, size_t>& init_num_reg_trials, |
| 108 | const std::unordered_map<image_t, size_t>& num_registrations) { |
| 109 | const size_t init_max_reg_trials = |
| 110 | static_cast<size_t>(options.init_max_reg_trials); |
| 111 | |
| 112 | // Collect information of all not yet registered images with |
| 113 | // correspondences. |
| 114 | std::vector<InitImageInfo> image_infos; |
| 115 | image_infos.reserve(reconstruction.NumImages()); |
| 116 | for (const auto& [image_id, image] : reconstruction.Images()) { |
| 117 | // Only images with correspondences can be registered. |
| 118 | if (correspondence_graph.NumCorrespondencesForImage(image_id) == 0) { |
| 119 | continue; |
| 120 | } |
| 121 | |
| 122 | // Only use images for initialization a maximum number of times. |
| 123 | if (const auto init_num_reg_trials_it = init_num_reg_trials.find(image_id); |
| 124 | init_num_reg_trials_it != init_num_reg_trials.end() && |
| 125 | init_num_reg_trials_it->second >= init_max_reg_trials) { |
| 126 | continue; |
| 127 | } |
| 128 | |
| 129 | // Only use images for initialization that are not registered in any |
| 130 | // of the other reconstructions. |
| 131 | if (const auto num_registrations_it = num_registrations.find(image_id); |
| 132 | num_registrations_it != num_registrations.end() && |
| 133 | num_registrations_it->second > 0) { |
| 134 | continue; |
| 135 | } |
| 136 | |
| 137 | image_infos.push_back( |
| 138 | {image_id, |
| 139 | image.CameraPtr()->has_prior_focal_length, |
| 140 | correspondence_graph.NumCorrespondencesForImage(image_id)}); |
| 141 | } |
| 142 | |
| 143 | return ExtractSortedImageIds(image_infos); |
| 144 | } |
| 145 | |
| 146 | std::vector<image_t> IncrementalMapperImpl::FindSecondInitialImage( |
| 147 | const IncrementalMapper::Options& options, |
nothing calls this directly
no test coverage detected