Use TriangulationParameters

release/4.3a0
cbeall3 2015-04-08 21:36:11 -04:00
parent 762a7b7435
commit ea6f5e3fb9
1 changed files with 20 additions and 25 deletions

View File

@ -40,15 +40,18 @@ template<class CALIBRATION>
class SmartStereoProjectionFactor: public SmartFactorBase<StereoCamera> { class SmartStereoProjectionFactor: public SmartFactorBase<StereoCamera> {
protected: protected:
// Some triangulation parameters /// @name Caching triangulation
const double rankTolerance_; ///< threshold to decide whether triangulation is degenerate_ /// @{
const TriangulationParameters parameters_;
// TODO:
// mutable TriangulationResult result_; ///< result from triangulateSafe
const double retriangulationThreshold_; ///< threshold to decide whether to re-triangulate const double retriangulationThreshold_; ///< threshold to decide whether to re-triangulate
mutable std::vector<Pose3> cameraPosesTriangulation_; ///< current triangulation poses mutable std::vector<Pose3> cameraPosesTriangulation_; ///< current triangulation poses
/// @}
const bool manageDegeneracy_; ///< if set to true will use the rotation-only version for degenerate cases const bool manageDegeneracy_; ///< if set to true will use the rotation-only version for degenerate cases
const bool enableEPI_; ///< if set to true, will refine triangulation using LM
const double linearizationThreshold_; ///< threshold to decide whether to re-linearize const double linearizationThreshold_; ///< threshold to decide whether to re-linearize
mutable std::vector<Pose3> cameraPosesLinearization_; ///< current linearization poses mutable std::vector<Pose3> cameraPosesLinearization_; ///< current linearization poses
@ -61,13 +64,6 @@ protected:
/// shorthand for base class type /// shorthand for base class type
typedef SmartFactorBase<StereoCamera> Base; typedef SmartFactorBase<StereoCamera> Base;
double landmarkDistanceThreshold_; // if the landmark is triangulated at a
// distance larger than that the factor is considered degenerate
double dynamicOutlierRejectionThreshold_; // if this is nonnegative the factor will check if the
// average reprojection error is smaller than this threshold after triangulation,
// and the factor is disregarded if the error is large
/// shorthand for this class /// shorthand for this class
typedef SmartStereoProjectionFactor<CALIBRATION> This; typedef SmartStereoProjectionFactor<CALIBRATION> This;
@ -101,16 +97,15 @@ public:
* @param enableEPI if set to true linear triangulation is refined with embedded LM iterations * @param enableEPI if set to true linear triangulation is refined with embedded LM iterations
* @param body_P_sensor is the transform from body to sensor frame (default identity) * @param body_P_sensor is the transform from body to sensor frame (default identity)
*/ */
SmartStereoProjectionFactor(const double rankTol, const double linThreshold, SmartStereoProjectionFactor(const double rankTolerance,
const bool manageDegeneracy, const bool enableEPI, const double linThreshold, const bool manageDegeneracy,
double landmarkDistanceThreshold = 1e10, const bool enableEPI, double landmarkDistanceThreshold = 1e10,
double dynamicOutlierRejectionThreshold = -1) : double dynamicOutlierRejectionThreshold = -1) :
rankTolerance_(rankTol), retriangulationThreshold_(1e-5), manageDegeneracy_( parameters_(rankTolerance, enableEPI, landmarkDistanceThreshold,
manageDegeneracy), enableEPI_(enableEPI), linearizationThreshold_( dynamicOutlierRejectionThreshold), //
retriangulationThreshold_(1e-5), manageDegeneracy_(manageDegeneracy), linearizationThreshold_(
linThreshold), degenerate_(false), cheiralityException_(false), throwCheirality_( linThreshold), degenerate_(false), cheiralityException_(false), throwCheirality_(
false), verboseCheirality_(false), landmarkDistanceThreshold_( false), verboseCheirality_(false) {
landmarkDistanceThreshold), dynamicOutlierRejectionThreshold_(
dynamicOutlierRejectionThreshold) {
} }
/** Virtual destructor */ /** Virtual destructor */
@ -124,8 +119,8 @@ public:
*/ */
void print(const std::string& s = "", const KeyFormatter& keyFormatter = void print(const std::string& s = "", const KeyFormatter& keyFormatter =
DefaultKeyFormatter) const { DefaultKeyFormatter) const {
std::cout << s << "SmartStereoProjectionFactor, z = \n"; std::cout << s << "SmartStereoProjectionFactor\n";
std::cout << "rankTolerance_ = " << rankTolerance_ << std::endl; std::cout << "triangulationParameters:\n" << parameters_ << std::endl;
std::cout << "degenerate_ = " << degenerate_ << std::endl; std::cout << "degenerate_ = " << degenerate_ << std::endl;
std::cout << "cheiralityException_ = " << cheiralityException_ << std::endl; std::cout << "cheiralityException_ = " << cheiralityException_ << std::endl;
std::cout << "linearizationThreshold_ = " << linearizationThreshold_ std::cout << "linearizationThreshold_ = " << linearizationThreshold_
@ -206,7 +201,7 @@ public:
mono_cameras.push_back(PinholeCamera<Cal3_S2>(pose, K)); mono_cameras.push_back(PinholeCamera<Cal3_S2>(pose, K));
} }
point_ = triangulatePoint3<Cal3_S2>(mono_cameras, mono_measurements, point_ = triangulatePoint3<Cal3_S2>(mono_cameras, mono_measurements,
rankTolerance_, enableEPI_); parameters_.rankTolerance, parameters_.enableEPI);
// // // End temporary hack // // // End temporary hack
@ -223,7 +218,7 @@ public:
BOOST_FOREACH(const Camera& camera, cameras) { BOOST_FOREACH(const Camera& camera, cameras) {
Point3 cameraTranslation = camera.pose().translation(); Point3 cameraTranslation = camera.pose().translation();
// we discard smart factors corresponding to points that are far away // we discard smart factors corresponding to points that are far away
if (cameraTranslation.distance(point_) > landmarkDistanceThreshold_) { if (cameraTranslation.distance(point_) > parameters_.landmarkDistanceThreshold) {
degenerate_ = true; degenerate_ = true;
break; break;
} }
@ -238,8 +233,8 @@ public:
} }
//std::cout << "totalReprojError error: " << totalReprojError << std::endl; //std::cout << "totalReprojError error: " << totalReprojError << std::endl;
// we discard smart factors that have large reprojection error // we discard smart factors that have large reprojection error
if (dynamicOutlierRejectionThreshold_ > 0 if (parameters_.dynamicOutlierRejectionThreshold > 0
&& totalReprojError / m > dynamicOutlierRejectionThreshold_) && totalReprojError / m > parameters_.dynamicOutlierRejectionThreshold)
degenerate_ = true; degenerate_ = true;
} catch (TriangulationUnderconstrainedException&) { } catch (TriangulationUnderconstrainedException&) {