Skip to content

Commit 1d586f7

Browse files
committed
[filterSfM] update code to follow latest merges
1 parent 7aae1a0 commit 1d586f7

File tree

2 files changed

+31
-30
lines changed

2 files changed

+31
-30
lines changed

src/software/pipeline/main_filterSfM.cpp

+21-22
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ struct ObservationsAdaptator
165165
inline size_t kdtree_get_point_count() const { return _data.size(); }
166166

167167
// Returns the dim'th component of the idx'th point in the class:
168-
inline T kdtree_get_pt(const size_t idx, int dim) const { return _data[idx].x(dim); }
168+
inline T kdtree_get_pt(const size_t idx, int dim) const { return _data[idx].getCoordinates()(dim); }
169169

170170
// Optional bounding-box computation: return false to default to a standard bbox computation loop.
171171
// Return true if the BBOX was already computed by the class and returned in "bb" so it can be avoided to redo it
@@ -353,7 +353,7 @@ ObservationsPerView getObservationsPerViews(SfMData& sfmData)
353353
ObservationsPerView observationsPerView;
354354
for(auto& landIt : sfmData.getLandmarks())
355355
{
356-
for(const auto& obsIt : landIt.second.observations)
356+
for(const auto& obsIt : landIt.second.getObservations())
357357
{
358358
IndexT viewId = obsIt.first;
359359
auto& landmarksSet = observationsPerView[viewId];
@@ -376,7 +376,7 @@ void filterLandmarks_step1(SfMData& sfmData,
376376
ALICEVISION_LOG_INFO("Removing landmarks having an insufficient number of observations: started.");
377377
for(auto& it : sfmData.getLandmarks())
378378
{
379-
if(it.second.observations.size() < params.minNbObservationsPerLandmark)
379+
if (it.second.getObservations().size() < params.minNbObservationsPerLandmark)
380380
continue;
381381
landmarksData[i++] = it.second;
382382
}
@@ -415,10 +415,10 @@ void filterLandmarks_step2(SfMData& sfmData,
415415
for(auto i = 0; i < landmarksData.size(); i++)
416416
{
417417
const sfmData::Landmark& landmark = landmarksData[i];
418-
const auto& nbObservations = landmark.observations.size();
418+
const auto& nbObservations = landmark.getObservations().size();
419419
auto& [viewIds, neighbors] = viewData[i];
420420
viewIds.reserve(nbObservations);
421-
for(const auto& observationPair : landmark.observations)
421+
for (const auto& observationPair : landmark.getObservations())
422422
{
423423
const IndexT viewId = observationPair.first;
424424
viewIds.push_back(viewId);
@@ -504,12 +504,12 @@ void filterLandmarks_step3(SfMData& sfmData,
504504
// compute landmark pixSize
505505
double pixSize = 0.;
506506
int n = 0;
507-
for(const auto& observationPair : landmark.observations)
507+
for (const auto& observationPair : landmark.getObservations())
508508
{
509509
const IndexT viewId = observationPair.first;
510510
pixSize += mp.getCamPixelSize(Point3d(landmark.X.x(), landmark.X.y(), landmark.X.z()),
511511
mp.getIndexFromViewId(viewId),
512-
params.useFeatureScale ? observationPair.second.scale : 1);
512+
params.useFeatureScale ? observationPair.second.getScale() : 1);
513513
n++;
514514
}
515515
pixSize /= n;
@@ -594,13 +594,13 @@ void computeInitialObservationScores(SfMData& sfmData, std::vector<Landmark*>& l
594594
const sfmData::Landmark& landmark = *landmarksData[i];
595595

596596
// compute observation scores
597-
const auto& nbObservations = landmark.observations.size();
597+
const auto& nbObservations = landmark.getObservations().size();
598598
auto& [viewIds, viewScores] = viewScoresData[i];
599599
viewIds.reserve(nbObservations);
600600
viewScores.reserve(nbObservations);
601601
// accumulator for normalizing the scores
602602
double total = 0.;
603-
for(const auto& observationPair : landmark.observations)
603+
for (const auto& observationPair : landmark.getObservations())
604604
{
605605
const IndexT viewId = observationPair.first;
606606
const sfmData::View& view = *(sfmData.getViews().at(viewId));
@@ -869,7 +869,7 @@ void removeNonObservedLandmarks(SfMData& sfmData)
869869
const auto& initialNbLandmarks = sfmData.getLandmarks().size();
870870
for(auto it = sfmData.getLandmarks().begin(); it != sfmData.getLandmarks().end();)
871871
{
872-
if(it->second.observations.size() == 0)
872+
if (it->second.getObservations().size() == 0)
873873
it = sfmData.getLandmarks().erase(it);
874874
else
875875
++it;
@@ -920,14 +920,13 @@ bool filterObservations3D(SfMData& sfmData, const FilterParams::FilterObservatio
920920

921921
// keep only observations with best scores
922922
Observations filteredObservations;
923-
size_t maxNbObservationsPerLandmark =
924-
std::min(static_cast<size_t>(params.maxNbObservationsPerLandmark), landmark.observations.size());
923+
size_t maxNbObservationsPerLandmark = std::min(static_cast<size_t>(params.maxNbObservationsPerLandmark), landmark.getObservations().size());
925924
for(auto j = 0; j < maxNbObservationsPerLandmark; j++)
926925
{
927926
// add observation only if it's an original observation and not augmented
928927
const auto& viewId = viewIds[idx[j]];
929-
const auto& obsIt = landmark.observations.find(viewId);
930-
if(obsIt != landmark.observations.end())
928+
const auto& obsIt = landmark.getObservations().find(viewId);
929+
if (obsIt != landmark.getObservations().end())
931930
filteredObservations[viewId] = obsIt->second;
932931
else if (params.observationsPropagationKeep)
933932
{
@@ -939,7 +938,7 @@ bool filterObservations3D(SfMData& sfmData, const FilterParams::FilterObservatio
939938
filteredObservations[viewId] = Observation(x, UndefinedIndexT, 0.0);
940939
}
941940
}
942-
landmark.observations = std::move(filteredObservations);
941+
landmark.getObservations() = std::move(filteredObservations);
943942
}
944943
ALICEVISION_LOG_INFO("Selecting observations with best scores: done");
945944

@@ -970,7 +969,7 @@ double filter2DView(SfMData& sfmData, const FilterParams::FilterObservations2DPa
970969
std::vector<double> distances_(nbNeighbors_);
971970
KnnNonZeroSearch resultSet(nbNeighbors_);
972971
resultSet.init(&indices_[0], &distances_[0]);
973-
tree.findNeighbors(resultSet, obs.x.data());
972+
tree.findNeighbors(resultSet, obs.getCoordinates().data());
974973
const auto& nbFound = resultSet.size();
975974
if(nbFound == 0)
976975
continue;
@@ -1023,7 +1022,7 @@ double filter2DView(SfMData& sfmData, const FilterParams::FilterObservations2DPa
10231022
}
10241023

10251024
bool filterObservations2D(SfMData& sfmData, const FilterParams::FilterObservations2DParams& params,
1026-
HashMap<IndexT, double>& estimatedRadii)
1025+
std::map<IndexT, double>& estimatedRadii)
10271026
{
10281027
std::set<IndexT> viewIds = sfmData.getValidViews();
10291028
std::vector<double> estimatedRadii_(viewIds.size(), -1.);
@@ -1046,7 +1045,7 @@ bool filterObservations2D(SfMData& sfmData, const FilterParams::FilterObservatio
10461045
// clear and update landmark observations
10471046
for(auto& landmark : sfmData.getLandmarks())
10481047
{
1049-
landmark.second.observations.clear();
1048+
landmark.second.getObservations().clear();
10501049
}
10511050
for(int i = 0; i < viewIds.size(); ++i)
10521051
{
@@ -1064,7 +1063,7 @@ bool filterObservations2D(SfMData& sfmData, const FilterParams::FilterObservatio
10641063
auto& landmarks = observationsIt->second.second;
10651064
for(int j = 0; j < observations.size(); j++)
10661065
{
1067-
landmarks[j]->observations[viewId] = observations[j];
1066+
landmarks[j]->getObservations()[viewId] = observations[j];
10681067
}
10691068
}
10701069
}
@@ -1163,7 +1162,7 @@ int aliceVision_main(int argc, char *argv[])
11631162

11641163
// Read the input SfM scene
11651164
SfMData sfmData;
1166-
if(!sfmDataIO::Load(sfmData, inputSfmFilename, sfmDataIO::ESfMData::ALL))
1165+
if(!sfmDataIO::load(sfmData, inputSfmFilename, sfmDataIO::ESfMData::ALL))
11671166
{
11681167
ALICEVISION_LOG_ERROR("The input SfMData file '" << inputSfmFilename << "' cannot be read.");
11691168
return EXIT_FAILURE;
@@ -1188,7 +1187,7 @@ int aliceVision_main(int argc, char *argv[])
11881187

11891188
if(params.filterObservations2D.enabled)
11901189
{
1191-
HashMap<IndexT, double> estimatedRadii;
1190+
std::map<IndexT, double> estimatedRadii;
11921191
ALICEVISION_LOG_INFO("Filtering observations in 2D: started.");
11931192
filterObservations2D(sfmData, params.filterObservations2D, estimatedRadii);
11941193
ALICEVISION_LOG_INFO("Filtering observations in 2D: done.");
@@ -1206,7 +1205,7 @@ int aliceVision_main(int argc, char *argv[])
12061205
}
12071206
}
12081207

1209-
sfmDataIO::Save(sfmData, outputSfmFilename, sfmDataIO::ESfMData::ALL);
1208+
sfmDataIO::save(sfmData, outputSfmFilename, sfmDataIO::ESfMData::ALL);
12101209
return EXIT_SUCCESS;
12111210

12121211
}

src/software/pipeline/main_prepareDenseScene.cpp

+10-8
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ ObservationsPerView getObservationsPerViews(const SfMData& sfmData)
9595
ObservationsPerView observationsPerView;
9696
for(auto& landIt : sfmData.getLandmarks())
9797
{
98-
for(const auto& obsIt : landIt.second.observations)
98+
for (const auto& obsIt : landIt.second.getObservations())
9999
{
100100
IndexT viewId = obsIt.first;
101101
auto& observationsSet = observationsPerView[viewId];
@@ -155,7 +155,7 @@ bool prepareDenseScene(const SfMData& sfmData,
155155

156156
bool doMaskLandmarks = landmarksMaskScale > 0.f;
157157
ObservationsPerView observationsPerView;
158-
HashMap<IndexT, double> estimatedRadii;
158+
std::map<IndexT, double> estimatedRadii;
159159
if (doMaskLandmarks)
160160
{
161161
observationsPerView = std::move(getObservationsPerViews(sfmData));
@@ -334,11 +334,13 @@ bool prepareDenseScene(const SfMData& sfmData,
334334
for(const auto& observation : observations)
335335
{
336336
const auto& obs = *observation;
337-
for(int y = std::max(obs.x.y() - r, 0.);
338-
y <= std::min(obs.x.y() + r, (double)maskLandmarks.Height() - 1); y++)
337+
for (int y = std::max(obs.getCoordinates().y() - r, 0.);
338+
y <= std::min(obs.getCoordinates().y() + r, (double)maskLandmarks.height() - 1);
339+
y++)
339340
{
340-
for(int x = std::max(obs.x.x() - r, 0.);
341-
x <= std::min(obs.x.x() + r, (double)maskLandmarks.Width() - 1); x++)
341+
for (int x = std::max(obs.getCoordinates().x() - r, 0.);
342+
x <= std::min(obs.getCoordinates().x() + r, (double)maskLandmarks.width() - 1);
343+
x++)
342344
{
343345
maskLandmarks(y, x) = std::numeric_limits<unsigned char>::max();
344346
}
@@ -356,13 +358,13 @@ bool prepareDenseScene(const SfMData& sfmData,
356358
dstColorImage, cam, metadata, srcImage, evCorrection, exposureCompensation,
357359
[&maskLoaded, &mask, &maskLandmarks, &doMaskLandmarks](Image<RGBAfColor>& image)
358360
{
359-
if(maskLoaded && (image.Width() * image.Height() != mask.Width() * mask.Height()))
361+
if(maskLoaded && (image.width() * image.height() != mask.width() * mask.height()))
360362
{
361363
ALICEVISION_LOG_WARNING("Invalid image mask size: mask is ignored.");
362364
return;
363365
}
364366

365-
for(int pix = 0; pix < image.Width() * image.Height(); ++pix)
367+
for(int pix = 0; pix < image.width() * image.height(); ++pix)
366368
{
367369
image(pix).a() = (maskLoaded && mask(pix) == 0) ? 0.f : (doMaskLandmarks && maskLandmarks(pix) == 127) ? .5f : 1.f;
368370
}

0 commit comments

Comments
 (0)