56 using namespace gtsam;
61 Vector3 axisAngle(0.1, 0.2, 0.3);
73 return base[cols * i +
j];
77 double r =
static_cast<double>(rand());
89 for (
int i = 0;
i < 3; ++
i) {
106 if (
operator()(P.
data(), X.data(), x.data()))
109 throw std::runtime_error(
"Projective fail");
124 P << 1, 0, 0, 0, 0, 1, 0, 5, 0, 0, 1, 0;
125 Vector4
X(10, 0, 5, 1);
129 Vector2 actual = projective(P, X);
133 Matrix E1 = numericalDerivative21<Vector2, RowMajorMatrix34, Vector4>(
135 Matrix E2 = numericalDerivative22<Vector2, RowMajorMatrix34, Vector4>(
142 double* jacobians[] = {H1.data(), H2.
data()};
143 CHECK((AutoDiff<Projective, double, 12, 4>::Differentiate(
144 projective, parameters, 2, actual2.data(), jacobians)));
155 if (snavely(P.data(), X.data(), x.data()))
158 throw std::runtime_error(
"Snavely fail");
166 Vector9
P =
Camera().localCoordinates(camera);
168 #ifdef GTSAM_POSE3_EXPMAP 181 #ifdef GTSAM_POSE3_EXPMAP 182 Vector9 expectedP = (Vector9() << 0.1, 0.2, 0.3, 0.7583528428, 4.9582357859, -0.224941471539, 1, 0, 0).finished();
184 Vector9 expectedP = (Vector9() << 0.1, 0.2, 0.3, 0, 5, 0, 1, 0, 0).finished();
208 double* jacobians[] = {H1.data(), H2.
data()};
209 CHECK((AutoDiff<SnavelyProjection, double, 9, 3>::Differentiate(
210 snavely, parameters, 2, actual2.data(), jacobians)));
230 Vector2 actual2 = snavely(P,
X, H1, H2);
Both ManifoldTraits and Testable.
Adaptor for Ceres style auto-differentiated functions.
Vector3 localCoordinates(const Cal3Bundler0 &T2) const
Concept check for values that can be used in unit tests.
static int runAllTests(TestResult &result)
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE const Scalar * data() const
PinholeCamera< Cal3Bundler0 > Camera
bool assert_equal(const Matrix &expected, const Matrix &actual, double tol)
Vector2 adapted(const Vector9 &P, const Vector3 &X)
T & RowMajorAccess(T *base, int rows, int cols, int i, int j)
Some functions to compute numerical derivatives.
static const Pose3 T2(Rot3::Rodrigues(0.3, 0.2, 0.1), P2)
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
Rot3 is a 3D rotation represented as a rotation matrix if the preprocessor symbol GTSAM_USE_QUATERNIO...
T upAligned(T value, unsigned requiredAlignment=TraceAlignment)
Cal3Bundler0(double f=0, double k1=0, double k2=0, double u0=0, double v0=0)
Expressions for Block Automatic Differentiation.
Base class for all pinhole cameras.
static Rot3 Rodrigues(const Vector3 &w)
#define EXPECT(condition)
double k1() const
distorsion parameter k1
double fx() const
focal length x
Point2(* f)(const Point3 &, OptionalJacobian< 2, 3 >)
Array< double, 1, 3 > e(1./3., 0.5, 2.)
static ConjugateGradientParameters parameters
bool equal_with_abs_tol(const Eigen::DenseBase< MATRIX > &A, const Eigen::DenseBase< MATRIX > &B, double tol=1e-9)
double k2() const
distorsion parameter k2
Calibration used by Bundler.
std::set< Key > keys() const
Return keys that play in this expression.
#define EXPECT_LONGS_EQUAL(expected, actual)
bool operator()(A const P[12], A const X[4], A x[2]) const
Vector2 operator()(const MatrixRowMajor &P, const Vector4 &X) const
double px() const
image center in x
Vector2 expectedMeasurement(1.2431567, 1.2525694)
Cal3Bundler0 retract(const Vector &d) const
Annotation indicating that a class derives from another given type.
TEST(SmartFactorBase, Pinhole)
The matrix class, also used for vectors and row-vectors.
Camera camera(Pose3(Rot3().retract(Vector3(0.1, 0.2, 0.3)), Point3(0, 5, 0)), Cal3Bundler0(1, 0, 0))
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
Calibration used by Bundler.
double py() const
image center in y
The most common 5DOF 3D->2D calibration.
size_t traceSize() const
Return size needed for memory buffer in traceExecution.
void AngleAxisToRotationMatrix(const T *angle_axis, T *R)