34 pair<Unit3, bool> SphericalCamera::projectSafe(
const Point3& pw)
const {
36 Unit3 pu = Unit3::FromPoint3(pc);
37 return make_pair(pu, pc.norm() > 1
e-8);
46 pose().transformTo(pw, Dpose ? &Dtf_pose : 0, Dpoint ? &Dtf_point : 0);
48 if (pc.norm() <= 1
e-8)
throw(
"point cannot be at the center of the camera");
51 Unit3 pu = Unit3::FromPoint3(
Point3(pc), Dpoint ? &Dunit : 0);
53 if (Dpose) *Dpose = Dunit * Dtf_pose;
54 if (Dpoint) *Dpoint = Dunit * Dtf_point;
63 const Unit3 pu =
pose().rotation().unrotate(pwu, Dpose ? &Dtf_rot : 0,
64 Dpoint ? &Dtf_point : 0);
67 *Dpose << Dtf_rot, Matrix::Zero(2, 3);
68 if (Dpoint) *Dpoint = Dtf_point;
74 return pose().transformFrom(depth * pu);
78 Unit3 SphericalCamera::backprojectPointAtInfinity(
const Unit3&
p)
const {
79 return pose().rotation().rotate(p);
86 return project2(point, Dcamera, Dpoint);
90 Vector2 SphericalCamera::reprojectionError(
94 if (Dpose || Dpoint) {
95 Matrix26 H_project_pose;
96 Matrix23 H_project_point;
98 Unit3 projected =
project2(point, H_project_pose, H_project_point);
100 if (Dpose) *Dpose = H_error * H_project_pose;
101 if (Dpoint) *Dpoint = H_error * H_project_point;
static Point2 project2(const CalibratedCamera &camera, const Point3 &point)
static Point2 project(const Pose3 &pose, const Unit3 &pointAtInfinity, const Cal3_S2::shared_ptr &cal)
int RealScalar int RealScalar int RealScalar * pc
Calibrated camera with spherical projection.
EIGEN_STRONG_INLINE Packet4f print(const Packet4f &a)
static Point3 backproject(const Pose3 &pose, const Point2 &point, const double &depth)
Represents a 3D point on a unit sphere.
Array< double, 1, 3 > e(1./3., 0.5, 2.)
const Pose3 & pose() const
return pose, constant version
static const Pose3 pose(Rot3(Vector3(1, -1, -1).asDiagonal()), Point3(0, 0, 0.5))
Vector2 errorVector(const Unit3 &q, OptionalJacobian< 2, 2 > H_p={}, OptionalJacobian< 2, 2 > H_q={}) const
static const CalibratedCamera camera(kDefaultPose)