handle chirelity exception

release/4.3a0
Yong-Dian Jian 2012-02-17 23:33:29 +00:00
parent e9ae2b5cc7
commit b735d30c7d
1 changed files with 13 additions and 8 deletions

View File

@ -77,15 +77,20 @@ namespace gtsam {
} }
/** h(x)-z */ /** h(x)-z */
Vector evaluateError( Vector evaluateError(const Cam& camera, const Point3& point,
const Cam& camera, boost::optional<Matrix&> H1=boost::none, boost::optional<Matrix&> H2=boost::none) const {
const Point3& point,
boost::optional<Matrix&> H1=boost::none,
boost::optional<Matrix&> H2=boost::none) const {
Vector error = z_.localCoordinates(camera.project2(point,H1,H2)); try {
// gtsam::print(error, "error"); Point2 reprojError(camera.project2(point,H1,H2) - z_);
return error; return reprojError.vector();
}
catch( CheiralityException& e) {
if (H1) *H1 = zeros(2, camera.dim());
if (H2) *H2 = zeros(2, point.dim());
// cout << e.what() << ": Landmark "<< this->key2_.index()
// << " behind Camera " << this->key1_.index() << endl;
return zero(2);
}
} }
/** return the measured */ /** return the measured */