Skip to content

Commit

Permalink
moving to squared sampson error
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushbaid committed Jun 9, 2021
1 parent e9738c7 commit 65211f8
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
12 changes: 7 additions & 5 deletions gtsam/geometry/EssentialMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,25 +154,27 @@ double EssentialMatrix::error(const Vector3& vA, const Vector3& vB,
Matrix15 numerator_H;
numerator_H << numerator_H_R, numerator_H_D;

*HE = numerator_H / denominator -
algebraic_error * denominator_H / (denominator * denominator);
*HE = 2 * sampson_error * (numerator_H / denominator -
algebraic_error * denominator_H / (denominator * denominator));
}

if (HvA){
Matrix13 numerator_H_vA = vB.transpose() * matrix().transpose();
Matrix13 denominator_H_vA = nA.transpose() * I * matrix().transpose() / denominator;

*HvA = numerator_H_vA / denominator - algebraic_error * denominator_H_vA / (denominator * denominator);
*HvA = 2 * sampson_error * (numerator_H_vA / denominator -
algebraic_error * denominator_H_vA / (denominator * denominator));
}

if (HvB){
Matrix13 numerator_H_vB = vA.transpose() * matrix();
Matrix13 denominator_H_vB = nB.transpose() * I * matrix() / denominator;

*HvB = numerator_H_vB / denominator - algebraic_error * denominator_H_vB / (denominator * denominator);
*HvB = 2 * sampson_error * (numerator_H_vB / denominator -
algebraic_error * denominator_H_vB / (denominator * denominator));
}

return sampson_error;
return sampson_error * sampson_error;
}

/* ************************************************************************* */
Expand Down
2 changes: 1 addition & 1 deletion gtsam/geometry/EssentialMatrix.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class EssentialMatrix {
return E.rotate(cRb);
}

/// epipolar error, sampson
/// epipolar error, sampson squared
GTSAM_EXPORT double error(const Vector3& vA, const Vector3& vB,
OptionalJacobian<1, 5> HE = boost::none,
OptionalJacobian<1, 3> HvA = boost::none,
Expand Down
4 changes: 2 additions & 2 deletions gtsam/geometry/tests/testEssentialMatrix.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,8 +254,8 @@ TEST(EssentialMatrix, errorValue) {
// algebraic error = 5
// norm of line for b = 1
// norm of line for a = 1
// sampson error = 5 / sqrt(1^2 + 1^2)
double expected = 3.535533906;
// sampson error = 5^2 / 1^2 + 1^2
double expected = 12.5;

// check the error
double actual = trueE.error(a, b);
Expand Down
8 changes: 4 additions & 4 deletions gtsam/slam/tests/testEssentialMatrixFactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ using namespace gtsam;

// Noise model for first type of factor is evaluating algebraic error
noiseModel::Isotropic::shared_ptr model1 = noiseModel::Isotropic::Sigma(1,
0.01);
1e-4);
// Noise model for second type of factor is evaluating pixel coordinates
noiseModel::Unit::shared_ptr model2 = noiseModel::Unit::Create(2);

Expand Down Expand Up @@ -196,9 +196,9 @@ TEST (EssentialMatrixFactor, minimization) {
(Vector(5) << 0.1, -0.1, 0.1, 0.1, -0.1).finished());
initial.insert(1, initialE);
#if defined(GTSAM_ROT3_EXPMAP) || defined(GTSAM_USE_QUATERNIONS)
EXPECT_DOUBLES_EQUAL(313.85, graph.error(initial), 1e-2);
EXPECT_DOUBLES_EQUAL(59403.51, graph.error(initial), 1e-2);
#else
EXPECT_DOUBLES_EQUAL(639.84, graph.error(initial), 1e-2);
EXPECT_DOUBLES_EQUAL(639.84, graph.error(initial), 1e-2); # TODO: redo this error
#endif

// Optimize
Expand Down Expand Up @@ -410,7 +410,7 @@ TEST (EssentialMatrixFactor, extraMinimization) {
initial.insert(1, initialE);

#if defined(GTSAM_ROT3_EXPMAP) || defined(GTSAM_USE_QUATERNIONS)
EXPECT_DOUBLES_EQUAL(313.85, graph.error(initial), 1e-2);
EXPECT_DOUBLES_EQUAL(59403.51, graph.error(initial), 1e-2);
#else
EXPECT_DOUBLES_EQUAL(639.84, graph.error(initial), 1e-2);
#endif
Expand Down

0 comments on commit 65211f8

Please sign in to comment.