Skip to content

Commit

Permalink
[sfm] do not set observation scale if featureConstraint is BASIC
Browse files Browse the repository at this point in the history
This disables the usage of scale in BA.
  • Loading branch information
fabiencastan committed Mar 20, 2020
1 parent 884a3f6 commit 9b0c623
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,9 @@ bool ReconstructionEngine_globalSfM::Compute_Initial_Structure(matching::Pairwis
const size_t imaIndex = it->first;
const size_t featIndex = it->second;
const PointFeature & pt = _featuresPerView->getFeatures(imaIndex, track.descType)[featIndex];
obs[imaIndex] = Observation(pt.coords().cast<double>(), featIndex, pt.scale());

const double scale = (_featureConstraint == EFeatureConstraint::BASIC) ? 0.0 : pt.scale();
obs[imaIndex] = Observation(pt.coords().cast<double>(), featIndex, scale);
}
}

Expand Down Expand Up @@ -443,7 +445,6 @@ void ReconstructionEngine_globalSfM::Compute_Relative_Rotations(rotationAveragin
poseWiseMatches[Pair(v1->getPoseId(), v2->getPoseId())].insert(pair);
}

const double unknownScale = 0.0;
boost::progress_display progressBar( poseWiseMatches.size(), std::cout, "\n- Relative pose computation -\n" );
#pragma omp parallel for schedule(dynamic)
// Compute the relative pose from pairwise point matches:
Expand Down Expand Up @@ -564,8 +565,10 @@ void ReconstructionEngine_globalSfM::Compute_Relative_Rotations(rotationAveragin
Vec3 X;
TriangulateDLT(P1, x1_, P2, x2_, &X);
Observations obs;
obs[view_I->getViewId()] = Observation(x1_, match._i, p1.scale());
obs[view_J->getViewId()] = Observation(x2_, match._j, p2.scale());
const double scaleI = (_featureConstraint == EFeatureConstraint::BASIC) ? 0.0 : p1.scale();
const double scaleJ = (_featureConstraint == EFeatureConstraint::BASIC) ? 0.0 : p2.scale();
obs[view_I->getViewId()] = Observation(x1_, match._i, scaleI);
obs[view_J->getViewId()] = Observation(x2_, match._j, scaleJ);
Landmark& newLandmark = landmarks[landmarkId++];
newLandmark.descType = descType;
newLandmark.observations = obs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1662,7 +1662,7 @@ void ReconstructionEngine_sequentialSfM::updateScene(const IndexT viewIndex, con
{
Landmark& landmark = _sfmData.structure[*iterTrackId];
const IndexT idFeat = resectionData.featuresId[i].second;
const double scale = _featuresPerView->getFeatures(viewIndex, landmark.descType)[idFeat].scale();
const double scale = (_params.featureConstraint == EFeatureConstraint::BASIC) ? 0.0 : _featuresPerView->getFeatures(viewIndex, landmark.descType)[idFeat].scale();
// Inlier, add the point to the reconstructed track
landmark.observations[viewIndex] = Observation(x, idFeat, scale);
}
Expand Down Expand Up @@ -1877,7 +1877,8 @@ void ReconstructionEngine_sequentialSfM::triangulate_multiViewsLORANSAC(SfMData&
{
const Vec2 x = _featuresPerView->getFeatures(viewId, track.descType)[track.featPerView.at(viewId)].coords().cast<double>();
const feature::PointFeature& p = _featuresPerView->getFeatures(viewId, track.descType)[track.featPerView.at(viewId)];
landmark.observations[viewId] = Observation(x, track.featPerView.at(viewId), p.scale());
const double scale = (_params.featureConstraint == EFeatureConstraint::BASIC) ? 0.0 : p.scale();
landmark.observations[viewId] = Observation(x, track.featPerView.at(viewId), scale);
}
#pragma omp critical
{
Expand Down Expand Up @@ -1971,7 +1972,8 @@ void ReconstructionEngine_sequentialSfM::triangulate_2Views(SfMData& scene, cons
const double acThreshold = (acThresholdIt != _map_ACThreshold.end()) ? acThresholdIt->second : 4.0;
if (poseI.depth(landmark.X) > 0 && residual.norm() < std::max(4.0, acThreshold))
{
landmark.observations[I] = Observation(xI, track.featPerView.at(I), featI.scale());
const double scale = (_params.featureConstraint == EFeatureConstraint::BASIC) ? 0.0 : featI.scale();
landmark.observations[I] = Observation(xI, track.featPerView.at(I), scale);
++extented_track;
}
}
Expand All @@ -1983,7 +1985,8 @@ void ReconstructionEngine_sequentialSfM::triangulate_2Views(SfMData& scene, cons
const double acThreshold = (acThresholdIt != _map_ACThreshold.end()) ? acThresholdIt->second : 4.0;
if (poseJ.depth(landmark.X) > 0 && residual.norm() < std::max(4.0, acThreshold))
{
landmark.observations[J] = Observation(xJ, track.featPerView.at(J), featJ.scale());
const double scale = (_params.featureConstraint == EFeatureConstraint::BASIC) ? 0.0 : featJ.scale();
landmark.observations[J] = Observation(xJ, track.featPerView.at(J), scale);
++extented_track;
}
}
Expand Down Expand Up @@ -2034,8 +2037,10 @@ void ReconstructionEngine_sequentialSfM::triangulate_2Views(SfMData& scene, cons
landmark.X = X_euclidean;
landmark.descType = track.descType;

landmark.observations[I] = Observation(xI, track.featPerView.at(I), featI.scale());
landmark.observations[J] = Observation(xJ, track.featPerView.at(J), featJ.scale());
const double scaleI = (_params.featureConstraint == EFeatureConstraint::BASIC) ? 0.0 : featI.scale();
const double scaleJ = (_params.featureConstraint == EFeatureConstraint::BASIC) ? 0.0 : featJ.scale();
landmark.observations[I] = Observation(xI, track.featPerView.at(I), scaleI);
landmark.observations[J] = Observation(xJ, track.featPerView.at(J), scaleJ);

++new_added_track;
} // critical
Expand Down

0 comments on commit 9b0c623

Please sign in to comment.