MCPcopy Create free account
hub / github.com/colmap/colmap / FindSecondInitialImage

Method FindSecondInitialImage

src/colmap/sfm/incremental_mapper_impl.cc:146–186  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

144}
145
146std::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
188bool IncrementalMapperImpl::FindInitialImagePair(
189 const IncrementalMapper::Options& options,

Callers

nothing calls this directly

Calls 7

ExtractSortedImageIdsFunction · 0.85
NumPoints2DMethod · 0.80
FindCorrespondencesMethod · 0.80
sizeMethod · 0.80
CameraPtrMethod · 0.80
ImageMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected