Cheirality check for Projection Factor with Calibrated Camera.
parent
5a75c9e963
commit
33c15dd423
|
|
@ -61,6 +61,8 @@ Point2 CalibratedCamera::project(const Point3& point,
|
||||||
const Rot3& R = pose.rotation();
|
const Rot3& R = pose.rotation();
|
||||||
const Point3& r1 = R.r1(), r2 = R.r2(), r3 = R.r3();
|
const Point3& r1 = R.r1(), r2 = R.r2(), r3 = R.r3();
|
||||||
Point3 q = pose.transform_to(point);
|
Point3 q = pose.transform_to(point);
|
||||||
|
if(q.z() <= 0)
|
||||||
|
throw CheiralityException();
|
||||||
|
|
||||||
if (D_intrinsic_pose || D_intrinsic_point) {
|
if (D_intrinsic_pose || D_intrinsic_point) {
|
||||||
double X = q.x(), Y = q.y(), Z = q.z();
|
double X = q.x(), Y = q.y(), Z = q.z();
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,11 @@
|
||||||
|
|
||||||
namespace gtsam {
|
namespace gtsam {
|
||||||
|
|
||||||
|
class CheiralityException: public std::runtime_error {
|
||||||
|
public:
|
||||||
|
CheiralityException() : std::runtime_error("Cheirality Exception") {}
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A Calibrated camera class [R|-R't], calibration K=I.
|
* A Calibrated camera class [R|-R't], calibration K=I.
|
||||||
* If calibration is known, it is more computationally efficient
|
* If calibration is known, it is more computationally efficient
|
||||||
|
|
|
||||||
|
|
@ -82,9 +82,18 @@ namespace gtsam {
|
||||||
/// Evaluate error h(x)-z and optionally derivatives
|
/// Evaluate error h(x)-z and optionally derivatives
|
||||||
Vector evaluateError(const Pose3& pose, const Point3& point,
|
Vector evaluateError(const Pose3& pose, const Point3& point,
|
||||||
boost::optional<Matrix&> H1, boost::optional<Matrix&> H2) const {
|
boost::optional<Matrix&> H1, boost::optional<Matrix&> H2) const {
|
||||||
SimpleCamera camera(*K_, pose);
|
try {
|
||||||
Point2 reprojectionError(camera.project(point, H1, H2) - z_);
|
SimpleCamera camera(*K_, pose);
|
||||||
return reprojectionError.vector();
|
Point2 reprojectionError(camera.project(point, H1, H2) - z_);
|
||||||
|
return reprojectionError.vector();
|
||||||
|
}
|
||||||
|
catch( CheiralityException& e) {
|
||||||
|
if (H1) *H1 = zeros(2,6);
|
||||||
|
if (H2) *H2 = zeros(2,3);
|
||||||
|
cout << e.what() << ": Landmark "<< this->key2_.index() <<
|
||||||
|
" moved behind camera " << this->key1_.index() << endl;
|
||||||
|
return zero(2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/** return the measurement */
|
/** return the measurement */
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue