Skip to content

Commit 64ff24b

Browse files
committed
using fixed size matrix, and adding jacobian in homogeneous conversion
1 parent f60e9e9 commit 64ff24b

File tree

6 files changed

+358
-666
lines changed

6 files changed

+358
-666
lines changed

gtsam/geometry/EssentialMatrix.h

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@
77

88
#pragma once
99

10+
#include <gtsam/base/Manifold.h>
11+
#include <gtsam/geometry/Point2.h>
1012
#include <gtsam/geometry/Pose3.h>
1113
#include <gtsam/geometry/Unit3.h>
12-
#include <gtsam/geometry/Point2.h>
13-
#include <gtsam/base/Manifold.h>
1414

1515
#include <iosfwd>
1616
#include <string>
@@ -31,7 +31,11 @@ class EssentialMatrix {
3131

3232
public:
3333
/// Static function to convert Point2 to homogeneous coordinates
34-
static Vector3 Homogeneous(const Point2& p) {
34+
static Vector3 Homogeneous(const Point2& p,
35+
OptionalJacobian<3, 2> H = boost::none) {
36+
if (H) {
37+
H->setIdentity();
38+
}
3539
return Vector3(p.x(), p.y(), 1);
3640
}
3741

gtsam/geometry/tests/testEssentialMatrix.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,18 @@ TEST (EssentialMatrix, epipoles) {
241241
EXPECT(assert_equal(e2, E.epipole_b()));
242242
}
243243

244+
//*************************************************************************
245+
TEST(EssentialMatrix, Homogeneous) {
246+
Point2 input(5.0, 1.3);
247+
Vector3 expected(5.0, 1.3, 1.0);
248+
Matrix32 expectedH;
249+
expectedH << 1.0, 0.0, 0.0, 1.0, 0.0, 0.0;
250+
Matrix32 actualH;
251+
Vector3 actual = EssentialMatrix::Homogeneous(input, actualH);
252+
EXPECT(assert_equal(actual, expected));
253+
EXPECT(assert_equal(actualH, expectedH));
254+
}
255+
244256
/* ************************************************************************* */
245257
int main() {
246258
TestResult tr;

0 commit comments

Comments
 (0)