Skip to content

Commit 74cf191

Browse files
almaroukcbentejac
authored andcommitted
[sfm] code clarity
1 parent 126baff commit 74cf191

File tree

1 file changed

+25
-22
lines changed

1 file changed

+25
-22
lines changed

src/aliceVision/track/TracksBuilder.cpp

+25-22
Original file line numberDiff line numberDiff line change
@@ -150,8 +150,7 @@ void mergeTracks(const feature::MapFeaturesPerView& featuresPerView,
150150
// map of (descType) to
151151
// map of DuplicateFeatureId(x, y, scale) to
152152
// pair of (set<featureId>, node)
153-
HashMap<size_t,
154-
HashMap<feature::EImageDescriberType, HashMap<DuplicateFeatureId, std::pair<std::set<size_t>, const MapIndexToNode::mapped_type*>>>>
153+
HashMap<size_t, HashMap<feature::EImageDescriberType, HashMap<DuplicateFeatureId, std::pair<std::set<size_t>, MapIndexToNode::mapped_type>>>>
155154
duplicateFeaturesPerView;
156155

157156
// per viewId pair
@@ -182,38 +181,42 @@ void mergeTracks(const feature::MapFeaturesPerView& featuresPerView,
182181
{
183182
{
184183
auto& featureI = featuresI[m._i];
185-
auto& [duplicateFeatureIdsI, duplicateFeatureNodeI] =
186-
duplicateFeaturesI[DuplicateFeatureId(featureI.x(), featureI.y(), featureI.scale())];
187184
IndexedFeaturePair pairI(I, KeypointId(descType, m._i));
188185
auto& nodeI = map_indexToNode.at(pairI);
186+
DuplicateFeatureId duplicateIdI(featureI.x(), featureI.y(), featureI.scale());
187+
const auto& duplicateFeaturesI_it = duplicateFeaturesI.find(duplicateIdI);
189188
// if no duplicates yet found, add to map and update values
190-
if (duplicateFeatureNodeI == nullptr)
189+
if (duplicateFeaturesI_it == duplicateFeaturesI.end())
190+
duplicateFeaturesI[duplicateIdI] = std::make_pair(std::set<size_t>({m._i}), nodeI);
191+
else
191192
{
192-
duplicateFeatureIdsI.insert(m._i);
193-
duplicateFeatureNodeI = &nodeI;
194-
}
195-
// if not already in corresponding duplicates set, add to set and join nodes
196-
else if (duplicateFeatureIdsI.insert(m._i).second)
197-
{
198-
_d->tracksUF->join(nodeI, *duplicateFeatureNodeI);
193+
auto& duplicateFeatureIdsI = duplicateFeaturesI_it->second.first;
194+
auto& duplicateFeatureNodeI = duplicateFeaturesI_it->second.second;
195+
// if not already in corresponding duplicates set, add to set and join nodes
196+
if (duplicateFeatureIdsI.insert(m._i).second)
197+
{
198+
_d->tracksUF->join(nodeI, duplicateFeatureNodeI);
199+
}
199200
}
200201
}
201202
{
202203
auto& featureJ = featuresJ[m._j];
203-
auto& [duplicateFeatureIdsJ, duplicateFeatureNodeJ] =
204-
duplicateFeaturesJ[DuplicateFeatureId(featureJ.x(), featureJ.y(), featureJ.scale())];
205204
IndexedFeaturePair pairJ(J, KeypointId(descType, m._j));
206205
auto& nodeJ = map_indexToNode.at(pairJ);
206+
DuplicateFeatureId duplicateIdJ(featureJ.x(), featureJ.y(), featureJ.scale());
207+
const auto& duplicateFeaturesJ_it = duplicateFeaturesJ.find(duplicateIdJ);
207208
// if no duplicates yet found, add to map and update values
208-
if (duplicateFeatureNodeJ == nullptr)
209-
{
210-
duplicateFeatureIdsJ.insert(m._j);
211-
duplicateFeatureNodeJ = &nodeJ;
212-
}
213-
// if not already in corresponding duplicates set, add to set and join nodes
214-
else if (duplicateFeatureIdsJ.insert(m._j).second)
209+
if (duplicateFeaturesJ_it == duplicateFeaturesJ.end())
210+
duplicateFeaturesJ[duplicateIdJ] = std::make_pair(std::set<size_t>({m._j}), nodeJ);
211+
else
215212
{
216-
_d->tracksUF->join(nodeJ, *duplicateFeatureNodeJ);
213+
auto& duplicateFeatureIdsJ = duplicateFeaturesJ_it->second.first;
214+
auto& duplicateFeatureNodeJ = duplicateFeaturesJ_it->second.second;
215+
// if not already in corresponding duplicates set, add to set and join nodes
216+
if (duplicateFeatureIdsJ.insert(m._j).second)
217+
{
218+
_d->tracksUF->join(nodeJ, duplicateFeatureNodeJ);
219+
}
217220
}
218221
}
219222
}

0 commit comments

Comments
 (0)