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

Function ExtractTopScaleFeatures

src/colmap/feature/utils.cc:71–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

69}
70
71void ExtractTopScaleFeatures(FeatureKeypoints* keypoints,
72 FeatureDescriptors* descriptors,
73 const size_t num_features) {
74 THROW_CHECK_EQ(keypoints->size(), descriptors->data.rows());
75 THROW_CHECK_GT(num_features, 0);
76
77 if (static_cast<size_t>(descriptors->data.rows()) <= num_features) {
78 return;
79 }
80
81 std::vector<std::pair<size_t, float>> scales;
82 scales.reserve(keypoints->size());
83 for (size_t i = 0; i < keypoints->size(); ++i) {
84 scales.emplace_back(i, (*keypoints)[i].ComputeScale());
85 }
86
87 std::partial_sort(scales.begin(),
88 scales.begin() + num_features,
89 scales.end(),
90 [](const std::pair<size_t, float>& scale1,
91 const std::pair<size_t, float>& scale2) {
92 return scale1.second > scale2.second;
93 });
94
95 FeatureKeypoints top_scale_keypoints(num_features);
96 FeatureDescriptors top_scale_descriptors;
97 top_scale_descriptors.data.resize(num_features, descriptors->data.cols());
98 top_scale_descriptors.type = descriptors->type;
99 for (size_t i = 0; i < num_features; ++i) {
100 top_scale_keypoints[i] = (*keypoints)[scales[i].first];
101 top_scale_descriptors.data.row(i) = descriptors->data.row(scales[i].first);
102 }
103
104 *keypoints = std::move(top_scale_keypoints);
105 *descriptors = std::move(top_scale_descriptors);
106}
107
108} // namespace colmap

Callers 4

IndexImagesMethod · 0.85
QueryMethod · 0.85
RunVocabTreeRetrieverFunction · 0.85
TESTFunction · 0.85

Calls 4

sizeMethod · 0.80
ComputeScaleMethod · 0.80
beginMethod · 0.45
endMethod · 0.45

Tested by 1

TESTFunction · 0.68