27 Matrix26 PinholeBase::Dpose(
const Point2& pn,
double d) {
29 const double u = pn.x(),
v = pn.y();
30 double uv = u *
v, uu = u * u,
vv = v *
v;
32 Dpn_pose << uv, -1 - uu,
v, -
d, 0, d * u, 1 +
vv, -uv, -u, 0, -
d, d *
v;
37 Matrix23 PinholeBase::Dpoint(
const Point2& pn,
double d,
const Matrix3& Rt) {
39 const double u = pn.x(),
v = pn.y();
42 Rt(0, 0) - u * Rt(2, 0), Rt(0, 1) - u * Rt(2, 1), Rt(0, 2) - u * Rt(2, 2),
43 Rt(1, 0) -
v * Rt(2, 0), Rt(1, 1) -
v * Rt(2, 1), Rt(1, 2) -
v * Rt(2, 2);
51 const Point3 x(st, -ct, 0),
y(0, 0, -1),
z(ct, st, 0);
53 const Point3 t(pose2.
x(), pose2.
y(), height);
70 return pose_.equals(camera.
pose(),
tol);
75 pose_.print(s +
".pose");
82 H->block(0, 0, 6, 6) = I_6x6;
89 double d = 1.0 / pc.z();
90 const double u = pc.x() *
d,
v = pc.y() *
d;
92 *Dpoint <<
d, 0.0, -u *
d, 0.0,
d, -v *
d;
102 *Dpoint = Duv_point3 * Dpoint3_pc;
109 pair<Point2, bool> PinholeBase::projectSafe(
const Point3& pw)
const {
112 return make_pair(pn, pc.z() > 0);
120 const Point3 q =
pose().transformTo(point, {}, Dpoint ? &Rt : 0);
121 #ifdef GTSAM_THROW_CHEIRALITY_EXCEPTION 127 if (Dpose || Dpoint) {
128 const double d = 1.0 / q.z();
130 *Dpose = PinholeBase::Dpose(pn, d);
132 *Dpoint = PinholeBase::Dpoint(pn, d, Rt);
144 const Unit3 pc =
pose().rotation().unrotate(pw, Dpose ? &Dpc_rot : 0,
145 Dpoint ? &Dpc_point : 0);
146 #ifdef GTSAM_THROW_CHEIRALITY_EXCEPTION 152 const Point2 pn =
Project(pc, Dpose || Dpoint ? &Dpn_pc : 0);
159 Dpc_pose.leftCols<3>() = Dpc_rot;
160 *Dpose = Dpn_pc * Dpc_pose;
163 *Dpoint = Dpn_pc * Dpc_point;
172 *Ddepth << p.x(), p.y(), 1;
190 return project2(point, Dcamera, Dpoint);
200 return pose().localCoordinates(T2.
pose());
static Point2 project2(const CalibratedCamera &camera, const Point3 &point)
static Point2 project(const Pose3 &pose, const Unit3 &pointAtInfinity, const Cal3_S2::shared_ptr &cal)
Jet< T, N > cos(const Jet< T, N > &f)
Pose3_ getPose(const Expression< PinholeCamera< CALIBRATION > > &cam)
static Point3 BackprojectFromCamera(const CalibratedCamera &camera, const Point2 &point, const double &depth)
int RealScalar int RealScalar int RealScalar * pc
Vector3 unitVector(OptionalJacobian< 3, 2 > H={}) const
Return unit-norm Vector.
Jet< T, N > sin(const Jet< T, N > &f)
static const Pose3 T2(Rot3::Rodrigues(0.3, 0.2, 0.1), P2)
EIGEN_STRONG_INLINE Packet4f print(const Packet4f &a)
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 y set format x g set format y g set format x2 g set format y2 g set format z g set angles radians set nogrid set key title set key left top Right noreverse box linetype linewidth samplen spacing width set nolabel set noarrow set nologscale set logscale x set set pointsize set encoding default set nopolar set noparametric set set set set surface set nocontour set clabel set mapping cartesian set nohidden3d set cntrparam order set cntrparam linear set cntrparam levels auto set cntrparam points set size set set xzeroaxis lt lw set x2zeroaxis lt lw set yzeroaxis lt lw set y2zeroaxis lt lw set tics in set ticslevel set tics set mxtics default set mytics default set mx2tics default set my2tics default set xtics border mirror norotate autofreq set ytics border mirror norotate autofreq set ztics border nomirror norotate autofreq set nox2tics set noy2tics set timestamp bottom norotate set rrange [*:*] noreverse nowriteback set trange [*:*] noreverse nowriteback set urange [*:*] noreverse nowriteback set vrange [*:*] noreverse nowriteback set xlabel matrix size set x2label set timefmt d m y n H
Rot3 is a 3D rotation represented as a rotation matrix if the preprocessor symbol GTSAM_USE_QUATERNIO...
static const VectorValues vv
Represents a 3D point on a unit sphere.
Point3 cross(const Point3 &p, const Point3 &q, OptionalJacobian< 3, 3 > H1, OptionalJacobian< 3, 3 > H2)
cross product
const Pose3 & pose() const
return pose, constant version
double theta() const
get theta
Array< int, Dynamic, 1 > v
EIGEN_DEVICE_FUNC const Scalar & q
Calibrated camera for which only pose is unknown.
static const Pose3 pose(Rot3(Vector3(1, -1, -1).asDiagonal()), Point3(0, 0, 0.5))
Point2(* Project)(const Point3 &, OptionalJacobian< 2, 3 >)
Point3 point3(OptionalJacobian< 3, 2 > H={}) const
Return unit-norm Point3.
static const CalibratedCamera camera(kDefaultPose)
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