timeOneCameraExpression.cpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /* ----------------------------------------------------------------------------
  2. * GTSAM Copyright 2010, Georgia Tech Research Corporation,
  3. * Atlanta, Georgia 30332-0415
  4. * All Rights Reserved
  5. * Authors: Frank Dellaert, et al. (see THANKS for the full author list)
  6. * See LICENSE for the license information
  7. * -------------------------------------------------------------------------- */
  8. /**
  9. * @file timeOneCameraExpression.cpp
  10. * @brief time CalibratedCamera derivatives
  11. * @author Frank Dellaert
  12. * @date October 3, 2014
  13. */
  14. #include <gtsam/slam/expressions.h>
  15. #include <gtsam/nonlinear/ExpressionFactor.h>
  16. #include "timeLinearize.h"
  17. using namespace std;
  18. using namespace gtsam;
  19. #define time timeSingleThreaded
  20. int main() {
  21. // Create leaves
  22. Pose3_ x(1);
  23. Point3_ p(2);
  24. Cal3_S2_ K(3);
  25. // Some parameters needed
  26. Point2 z(-17, 30);
  27. SharedNoiseModel model = noiseModel::Unit::Create(2);
  28. // Create values
  29. Values values;
  30. values.insert(1, Pose3());
  31. values.insert(2, Point3(0, 0, 1));
  32. values.insert(3, Cal3_S2());
  33. // ExpressionFactor
  34. // Oct 3, 2014, Macbook Air
  35. // 20.3 musecs/call
  36. //#define TERNARY
  37. NonlinearFactor::shared_ptr f = boost::make_shared<ExpressionFactor<Point2> >
  38. #ifdef TERNARY
  39. (model, z, project3(x, p, K));
  40. #else
  41. (model, z, uncalibrate(K, project(transformTo(x, p))));
  42. #endif
  43. time("timing:", f, values);
  44. return 0;
  45. }