Skip to content

Commit

Permalink
[sfm] fix usage of observations scale in SfM
Browse files Browse the repository at this point in the history
* fix feature index in multiview triangulate
* fix removeOutliers for observations without scale
  • Loading branch information
fabiencastan committed Mar 19, 2020
1 parent 15d6db5 commit 4e01849
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/aliceVision/feature/sift/SIFT.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <aliceVision/feature/Descriptor.hpp>
#include <aliceVision/feature/ImageDescriber.hpp>
#include <aliceVision/feature/regionsFactory.hpp>
// #include <aliceVision/config.hpp> // TO CHECK
#include <aliceVision/config.hpp>
#include <aliceVision/system/Logger.hpp>

extern "C" {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1657,13 +1657,14 @@ void ReconstructionEngine_sequentialSfM::updateScene(const IndexT viewIndex, con
const Vec3 X = resectionData.pt3D.col(i);
const Vec2 x = resectionData.pt2D.col(i);
Landmark& landmark = _sfmData.structure[*iterTrackId];
double scale = _featuresPerView->getFeatures(viewIndex, landmark.descType)[i].scale(); // TODO: check i index, TODO: replace x() with scale()
const Vec2 residual = resectionData.optionalIntrinsic->residual(resectionData.pose, X, x);
if (residual.norm() < resectionData.error_max &&
resectionData.pose.depth(X) > 0)
{
const IndexT idFeat = resectionData.featuresId[i].second;
const double scale = _featuresPerView->getFeatures(viewIndex, landmark.descType)[idFeat].scale();
// Inlier, add the point to the reconstructed track
landmark.observations[viewIndex] = Observation(x, resectionData.featuresId[i].second, scale);
landmark.observations[viewIndex] = Observation(x, idFeat, scale);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/aliceVision/sfm/sfmFilters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ IndexT RemoveOutliers_PixelResidualError(sfmData::SfMData& sfmData,
const camera::IntrinsicBase * intrinsic = sfmData.intrinsics.at(view->getIntrinsicId()).get();

Vec2 residual = intrinsic->residual(pose, iterTracks->second.X, itObs->second.x);
if(featureConstraint == EFeatureConstraint::SCALE)
if(featureConstraint == EFeatureConstraint::SCALE && itObs->second.scale > 0.0)
{
// Apply the scale of the feature to get a residual value
// relative to the feature precision.
Expand Down
6 changes: 3 additions & 3 deletions src/aliceVision/sfmData/Landmark.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ namespace sfmData {
*/
struct Observation
{
Observation(): id_feat(UndefinedIndexT) {}
Observation() {}
Observation(const Vec2 & p, IndexT idFeat, double scale_)
: x(p)
, id_feat(idFeat)
, scale(scale_)
{}

Vec2 x;
IndexT id_feat;
double scale = 1.0;
IndexT id_feat = UndefinedIndexT;
double scale = 0.0;

bool operator==(const Observation& other) const
{
Expand Down
1 change: 0 additions & 1 deletion src/software/pipeline/main_incrementalSfM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@ int main(int argc, char **argv)
std::vector<std::string> matchesFolders;
std::string outputSfM;

// user optional parameters
// user optional parameters
std::string outputSfMViewsAndPoses;
std::string extraInfoFolder;
Expand Down
18 changes: 9 additions & 9 deletions src/software/utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -199,14 +199,14 @@ alicevision_add_software(aliceVision_utils_split360Images


# Project 180° fisheye images into equirectangular
#alicevision_add_software(aliceVision_utils_fisheyeProjection
# SOURCE main_fisheyeProjection.cpp
# FOLDER ${FOLDER_SOFTWARE_UTILS}
# LINKS aliceVision_system
# aliceVision_numeric
# aliceVision_image
# ${OPENIMAGEIO_LIBRARIES}
# ${Boost_LIBRARIES}
#)
alicevision_add_software(aliceVision_utils_fisheyeProjection
SOURCE main_fisheyeProjection.cpp
FOLDER ${FOLDER_SOFTWARE_UTILS}
LINKS aliceVision_system
aliceVision_numeric
aliceVision_image
${OPENIMAGEIO_LIBRARIES}
${Boost_LIBRARIES}
)

endif() # ALICEVISION_BUILD_SFM

0 comments on commit 4e01849

Please sign in to comment.