Skip to content

Commit

Permalink
Rewrite check on ambiguity in sfmTransform
Browse files Browse the repository at this point in the history
  • Loading branch information
servantftechnicolor committed Sep 4, 2023
1 parent 427d1a0 commit dca488a
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/aliceVision/sfm/utils/alignment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -608,18 +608,20 @@ void computeNewCoordinateSystemFromCamerasXAxis(const sfmData::SfMData& sfmData,
Eigen::Vector3d nullestSpace = solver.eigenvectors().col(minCol).real();
const Eigen::Vector3d referenceAxis = Eigen::Vector3d::UnitY();

const double d = nullestSpace.dot(meanRy);
// Compute the rotation which rotates nullestSpace onto unitY
out_R = Matrix3d(Quaterniond().setFromTwoVectors(nullestSpace, referenceAxis));
const double d = (out_R * meanRy).dot(Eigen::Vector3d::UnitY());
const bool inverseDirection = (d < 0.0);
// We have an ambiguity on the Y direction, so if our Y axis is not aligned with the Y axis of the scene
// we inverse the axis.
if(inverseDirection)
{
nullestSpace = -nullestSpace;
out_R = Matrix3d(Quaterniond().setFromTwoVectors(nullestSpace, referenceAxis));
}



// Compute the rotation which rotates nullestSpace onto unitY
out_R = Matrix3d(Quaterniond().setFromTwoVectors(nullestSpace, referenceAxis));

out_S = 1.0;
out_t = -out_R * meanCameraCenter;
}
Expand Down

0 comments on commit dca488a

Please sign in to comment.