| 144 | } |
| 145 | |
| 146 | std::vector<image_t> IncrementalMapperImpl::FindSecondInitialImage( |
| 147 | const IncrementalMapper::Options& options, |
| 148 | image_t image_id1, |
| 149 | const CorrespondenceGraph& correspondence_graph, |
| 150 | const Reconstruction& reconstruction, |
| 151 | const std::unordered_map<image_t, size_t>& num_registrations) { |
| 152 | // Collect images that are connected to the first seed image and have |
| 153 | // not been registered before in other reconstructions. |
| 154 | const class Image& image1 = reconstruction.Image(image_id1); |
| 155 | std::unordered_map<image_t, point2D_t> num_correspondences; |
| 156 | for (point2D_t point2D_idx = 0; point2D_idx < image1.NumPoints2D(); |
| 157 | ++point2D_idx) { |
| 158 | const auto corr_range = |
| 159 | correspondence_graph.FindCorrespondences(image_id1, point2D_idx); |
| 160 | for (const auto* corr = corr_range.beg; corr < corr_range.end; ++corr) { |
| 161 | if (const auto num_registrations_it = |
| 162 | num_registrations.find(corr->image_id); |
| 163 | num_registrations_it == num_registrations.end() || |
| 164 | num_registrations_it->second == 0) { |
| 165 | num_correspondences[corr->image_id] += 1; |
| 166 | } |
| 167 | } |
| 168 | } |
| 169 | |
| 170 | const size_t init_min_num_inliers = |
| 171 | static_cast<size_t>(options.init_min_num_inliers); |
| 172 | |
| 173 | // Compose image information in a compact form for sorting. |
| 174 | std::vector<InitImageInfo> image_infos; |
| 175 | image_infos.reserve(num_correspondences.size()); |
| 176 | for (const auto& [image_id, num_corrs] : num_correspondences) { |
| 177 | if (num_corrs >= init_min_num_inliers) { |
| 178 | const Image& image = reconstruction.Image(image_id); |
| 179 | image_infos.push_back({image_id, |
| 180 | image.CameraPtr()->has_prior_focal_length, |
| 181 | static_cast<size_t>(num_corrs)}); |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | return ExtractSortedImageIds(image_infos); |
| 186 | } |
| 187 | |
| 188 | bool IncrementalMapperImpl::FindInitialImagePair( |
| 189 | const IncrementalMapper::Options& options, |
nothing calls this directly
no test coverage detected